aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
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