summaryrefslogtreecommitdiff
path: root/src/unistd/execvp.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-09 13:14:01 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-09 13:14:01 -0500
commit253a32e2f9ff1cbb8edbe7c79834a678daebeb93 (patch)
tree599cf5baf01c6dae33a2f89989b08b7d553f7fd0 /src/unistd/execvp.c
parent88d0b5e7ffbf0554b236dc46225846061b5f4817 (diff)
merge POSIX.1-1988/1990
Diffstat (limited to 'src/unistd/execvp.c')
-rw-r--r--src/unistd/execvp.c20
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)
+*/