equal
deleted
inserted
replaced
4 */ |
4 */ |
5 |
5 |
6 #include <stdio.h> |
6 #include <stdio.h> |
7 #include <stdlib.h> |
7 #include <stdlib.h> |
8 #include <unistd.h> |
8 #include <unistd.h> |
9 #include <sys/time.h> |
|
10 #include <sys/resource.h> |
|
11 |
9 |
12 int set_limit (int); |
10 int set_limit (int); |
13 |
11 |
14 int main (int argc, char **argv) |
12 int main (int argc, char **argv) |
15 { |
13 { |
21 printf ("Usage: %s <mem> <cmd> [args]...\n", argv[0]); |
19 printf ("Usage: %s <mem> <cmd> [args]...\n", argv[0]); |
22 printf ("Report bugs to mbroeker@largo.homelinux.org\n"); |
20 printf ("Report bugs to mbroeker@largo.homelinux.org\n"); |
23 return EXIT_FAILURE; |
21 return EXIT_FAILURE; |
24 } |
22 } |
25 |
23 |
26 if ((args = calloc ((argc - 2), sizeof (char *))) == NULL) { |
24 if ((args = calloc ((argc - 1), sizeof (char *))) == NULL) { |
27 perror ("calloc"); |
25 perror ("calloc"); |
28 return EXIT_FAILURE; |
26 return EXIT_FAILURE; |
29 } |
27 } |
30 |
28 |
31 for (i = 2; i < argc; i++) |
29 for (i = 2; i < argc; i++) |
32 args[i - 2] = argv[i]; |
30 args[i - 2] = argv[i]; |
33 |
31 |
34 args[i] = NULL; |
32 args[i - 2] = NULL; |
35 |
33 |
36 if (set_limit (atoi (argv[1])) == 0) |
34 if (set_limit (atoi (argv[1])) == 0) { |
37 execvp (argv[2], args); |
35 i = execvp (argv[2], args); |
38 else |
36 } else { |
39 perror ("Limit Error"); |
37 perror ("Limit Error"); |
|
38 return EXIT_FAILURE; |
|
39 } |
40 |
40 |
41 if (args != NULL) |
41 if (args != NULL) |
42 free (args); |
42 free (args); |
43 |
43 |
44 return EXIT_SUCCESS; |
44 return i; |
45 } |
45 } |