]> pd.if.org Git - startuptools/blob - exec.c
fix empty module list handling
[startuptools] / exec.c
1 /*
2  * exec
3  */
4
5 #include <stdlib.h>
6 #include <stdio.h>
7
8 #include <sys/types.h>
9 #include <sys/stat.h>
10
11 #include <string.h>
12
13 #include <unistd.h>
14
15 static void do_exec(int skip, int ac, char *av[]) {
16         int i;
17
18         if (skip >= ac) {
19                 fprintf(stderr, "nothing to exec\n");
20                 exit(EXIT_FAILURE);
21         }
22
23         for (i=0;i<ac-skip;i++) {
24                 av[i] = av[i+skip];
25         }
26         av[i] = 0;
27
28         if (i = execvp(av[0], av) < 0) {
29                 fprintf(stderr, "exec returned %d: %s\n", i, strerror(i));
30         }
31 }