aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-06-14 01:24:33 +0000
committerRob Landley <rob@landley.net>2006-06-14 01:24:33 +0000
commitc7ddefc0624173de6b74ee5b5b39cb2d354f5ae6 (patch)
tree2e4ef7885c2e1d5cc436e9014207f2f05e86888d /libbb
parent575c8bacdaa0dd9f0f25719ec83ae505fbd3c382 (diff)
downloadbusybox-w32-c7ddefc0624173de6b74ee5b5b39cb2d354f5ae6.tar.gz
busybox-w32-c7ddefc0624173de6b74ee5b5b39cb2d354f5ae6.tar.bz2
busybox-w32-c7ddefc0624173de6b74ee5b5b39cb2d354f5ae6.zip
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')
-rw-r--r--libbb/xfuncs.c16
1 files changed, 15 insertions, 1 deletions
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 @@
9 9
10#include <sys/types.h> 10#include <sys/types.h>
11#include <sys/stat.h> 11#include <sys/stat.h>
12#include <sys/wait.h>
12#include <stdio.h> 13#include <stdio.h>
13#include <string.h> 14#include <string.h>
14#include <stdlib.h> 15#include <stdlib.h>
@@ -189,13 +190,14 @@ pid_t bb_spawn(char **argv)
189{ 190{
190 static int failed; 191 static int failed;
191 pid_t pid; 192 pid_t pid;
193 void *app = find_applet_by_name(argv[0]);
192 194
193 // Be nice to nommu machines. 195 // Be nice to nommu machines.
194 failed = 0; 196 failed = 0;
195 pid = vfork(); 197 pid = vfork();
196 if (pid < 0) return pid; 198 if (pid < 0) return pid;
197 if (!pid) { 199 if (!pid) {
198 execvp(*argv, argv); 200 execvp(app ? CONFIG_BUSYBOX_EXEC_PATH : *argv, argv);
199 201
200 // We're sharing a stack with blocked parent, let parent know we failed 202 // We're sharing a stack with blocked parent, let parent know we failed
201 // and then exit to unblock parent (but don't run atexit() stuff, which 203 // and then exit to unblock parent (but don't run atexit() stuff, which
@@ -216,3 +218,15 @@ pid_t bb_xspawn(char **argv)
216 return pid; 218 return pid;
217} 219}
218#endif 220#endif
221
222#ifdef L_wait4
223int wait4pid(int pid)
224{
225 int status;
226
227 if (pid == -1 || waitpid(pid, &status, 0) == -1) return -1;
228 if (WIFEXITED(status)) return WEXITSTATUS(status);
229 if (WIFSIGNALED(status)) return WTERMSIG(status);
230 return 0;
231}
232#endif