1: /*
2: * Exec a program with no environment.
3: */
4:
5: #include <stdio.h>
6:
7: extern int errno;
8: extern char *getenv(), *index();
9:
10: main (argc, argv)
11: int argc;
12: char *argv[];
13: {
14: execvep(argv[1], &argv[1], 0);
15: printf("exec failed, errno %d\n", errno);
16: }
17:
18: execvep (name, argv, envp)
19: char *name, *argv[], *envp[];
20: {
21: char *path;
22: register char *cp;
23: char fullname[1000];
24:
25: path = getenv("PATH");
26: if (path == NULL) {
27: path = "";
28: cp = NULL;
29: } else {
30: cp = index(path, ':');
31: }
32: for (;;) {
33: if (cp != NULL) {
34: *cp = '\0';
35: }
36: sprintf(fullname, "%s/%s", path, name);
37: execve(fullname, argv, envp);
38: if (cp != NULL) {
39: path = cp + 1;
40: cp = index(path, ':');
41: } else {
42: break;
43: }
44: }
45: return -1;
46: }
Defined functions
main
defined in line
10;
never used