prog_limit.c
changeset 60 47c13ca8c4d0
parent 51 a03372ef9714
child 64 993b97c4ad2d
--- a/prog_limit.c
+++ b/prog_limit.c
@@ -6,8 +6,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <sys/time.h>
-#include <sys/resource.h>
 
 int set_limit (int);
 
@@ -23,7 +21,7 @@
         return EXIT_FAILURE;
     }
 
-    if ((args = calloc ((argc - 2), sizeof (char *))) == NULL) {
+    if ((args = calloc ((argc - 1), sizeof (char *))) == NULL) {
         perror ("calloc");
         return EXIT_FAILURE;
     }
@@ -31,15 +29,17 @@
     for (i = 2; i < argc; i++)
         args[i - 2] = argv[i];
 
-    args[i] = NULL;
+    args[i - 2] = NULL;
 
-    if (set_limit (atoi (argv[1])) == 0)
-        execvp (argv[2], args);
-    else
+    if (set_limit (atoi (argv[1])) == 0) {
+        i = execvp (argv[2], args);
+    } else {
         perror ("Limit Error");
+        return EXIT_FAILURE;
+    }
 
     if (args != NULL)
         free (args);
 
-    return EXIT_SUCCESS;
+    return i;
 }