diff --git a/prog_limit.c b/prog_limit.c new file mode 100644 --- /dev/null +++ b/prog_limit.c @@ -0,0 +1,45 @@ +/** + * $Id: prog_limit.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $ + * $Source: /development/c/mem2swap/prog_limit.c,v $ + * + */ + +#include +#include +#include +#include +#include + +int set_limit (int); + +int main (int argc, char **argv) +{ + int i; + char **args; + + if (argc < 3) { + printf ("Usage: %s [args]...\n", argv[0]); + printf ("Report bugs to mbroeker@largo.homelinux.org\n"); + return EXIT_SUCCESS; + } + + if ((args = calloc ((argc - 2), sizeof (char *))) == NULL) { + perror ("calloc"); + return EXIT_FAILURE; + } + + for (i = 2; i < argc; i++) + args[i - 2] = argv[i]; + + args[i] = NULL; + + if (set_limit (atoi (argv[1]) * 1024 * 1024) == 0) + execvp (argv[2], args); + else + perror ("Limit Error"); + + if (args != NULL) + free (args); + + return EXIT_SUCCESS; +}