diff options
Diffstat (limited to 'src/unistd/execvp.c')
| -rw-r--r-- | src/unistd/execvp.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/unistd/execvp.c b/src/unistd/execvp.c new file mode 100644 index 00000000..5ad54781 --- /dev/null +++ b/src/unistd/execvp.c @@ -0,0 +1,20 @@ +#include "stddef.h" +#include "sys/types.h" +#include <unistd.h> +#include "errno.h" + +int execvp(const char *file, char *const argv[]) +{ + extern char **environ; + /* search $PATH for file */ + execve(file, argv, environ); + if (errno == ENOEXEC) { + /* stuff /bin/sh in front */ + char sh[] = "/bin/sh"; + return execve(sh, argv, environ); + } + return -1; +} +/* +POSIX(1) +*/ |
