aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-01-21 00:41:04 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-01-21 00:41:04 +0000
commitbb21944ea0d5e95f07691dfaeaba404ddfa70528 (patch)
tree3e82c2dd94d674a723f3d7df350f32dc8892adc1 /libbb
parentff978c7d73d84e06ee5dc927a180cdc794d35b21 (diff)
downloadbusybox-w32-bb21944ea0d5e95f07691dfaeaba404ddfa70528.tar.gz
busybox-w32-bb21944ea0d5e95f07691dfaeaba404ddfa70528.tar.bz2
busybox-w32-bb21944ea0d5e95f07691dfaeaba404ddfa70528.zip
Introduce FEATURE_EXEC_PREFER_APPLETS = "re-execute our own
executable if we asked to exec someting with argv[0] == known_applet" Use it in init. Also respect PATH in init, remove explicit "/sbin" etc from exec. Patch by Gabriel L. Somlo <somlo@cmu.edu> git-svn-id: svn://busybox.net/trunk/busybox@17426 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/xfuncs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 240ac5d3d..4252e7646 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -183,14 +183,17 @@ pid_t spawn(char **argv)
183 /* Why static? */ 183 /* Why static? */
184 static int failed; 184 static int failed;
185 pid_t pid; 185 pid_t pid;
186 void *app = ENABLE_FEATURE_SH_STANDALONE_SHELL ? find_applet_by_name(argv[0]) : 0; 186 char *prog;
187 187
188 // Be nice to nommu machines. 188 // Be nice to nommu machines.
189 failed = 0; 189 failed = 0;
190 pid = vfork(); 190 pid = vfork();
191 if (pid < 0) return pid; 191 if (pid < 0) return pid;
192 if (!pid) { 192 if (!pid) {
193 execvp(app ? CONFIG_BUSYBOX_EXEC_PATH : *argv, argv); 193 prog = argv[0];
194 if (ENABLE_FEATURE_EXEC_PREFER_APPLETS && find_applet_by_name(prog))
195 prog = CONFIG_BUSYBOX_EXEC_PATH;
196 execvp(prog, argv);
194 197
195 // We're sharing a stack with blocked parent, let parent know we failed 198 // We're sharing a stack with blocked parent, let parent know we failed
196 // and then exit to unblock parent (but don't run atexit() stuff, which 199 // and then exit to unblock parent (but don't run atexit() stuff, which