summaryrefslogtreecommitdiff
path: root/libbb/xfuncs.c
diff options
context:
space:
mode:
authorRob Landley2006-06-14 01:24:33 +0000
committerRob Landley2006-06-14 01:24:33 +0000
commitc7ddefc0624173de6b74ee5b5b39cb2d354f5ae6 (patch)
tree2e4ef7885c2e1d5cc436e9014207f2f05e86888d /libbb/xfuncs.c
parent575c8bacdaa0dd9f0f25719ec83ae505fbd3c382 (diff)
downloadbusybox-c7ddefc0624173de6b74ee5b5b39cb2d354f5ae6.zip
busybox-c7ddefc0624173de6b74ee5b5b39cb2d354f5ae6.tar.gz
Attempt at fixing bug 815 by upgrading bb_spawn() so that builtins are at
the start of the path. (This should be under the same config option as the standalone shell, but right now that's buried in the shell menu.) Also add the ability to specify CONFIG_BUSYBOX_EXEC_PATH with /proc/self/exe as an overrideable default.
Diffstat (limited to 'libbb/xfuncs.c')
-rw-r--r--libbb/xfuncs.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 2cfafb0..432fd60 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -9,6 +9,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/wait.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -189,13 +190,14 @@ pid_t bb_spawn(char **argv)
{
static int failed;
pid_t pid;
+ void *app = find_applet_by_name(argv[0]);
// Be nice to nommu machines.
failed = 0;
pid = vfork();
if (pid < 0) return pid;
if (!pid) {
- execvp(*argv, argv);
+ execvp(app ? CONFIG_BUSYBOX_EXEC_PATH : *argv, argv);
// We're sharing a stack with blocked parent, let parent know we failed
// and then exit to unblock parent (but don't run atexit() stuff, which
@@ -216,3 +218,15 @@ pid_t bb_xspawn(char **argv)
return pid;
}
#endif
+
+#ifdef L_wait4
+int wait4pid(int pid)
+{
+ int status;
+
+ if (pid == -1 || waitpid(pid, &status, 0) == -1) return -1;
+ if (WIFEXITED(status)) return WEXITSTATUS(status);
+ if (WIFSIGNALED(status)) return WTERMSIG(status);
+ return 0;
+}
+#endif