From c7ddefc0624173de6b74ee5b5b39cb2d354f5ae6 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 14 Jun 2006 01:24:33 +0000 Subject: 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. --- libbb/xfuncs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libbb') diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 2cfafb01a..432fd6079 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -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 -- cgit v1.2.3