aboutsummaryrefslogtreecommitdiff
path: root/libbb/vfork_daemon_rexec.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/vfork_daemon_rexec.c')
-rw-r--r--libbb/vfork_daemon_rexec.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index 766a89e5f..a6d260a40 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -185,26 +185,30 @@ int FAST_FUNC spawn_and_wait(char **argv)
185#if ENABLE_FEATURE_PREFER_APPLETS 185#if ENABLE_FEATURE_PREFER_APPLETS
186 int a = find_applet_by_name(argv[0]); 186 int a = find_applet_by_name(argv[0]);
187 187
188 if (a >= 0 && (APPLET_IS_NOFORK(a) 188 if (a >= 0) {
189# if BB_MMU
190 || APPLET_IS_NOEXEC(a) /* NOEXEC trick needs fork() */
191# endif
192 )) {
193# if BB_MMU
194 if (APPLET_IS_NOFORK(a)) 189 if (APPLET_IS_NOFORK(a))
195# endif
196 {
197 return run_nofork_applet(a, argv); 190 return run_nofork_applet(a, argv);
191# if BB_MMU /* NOEXEC needs fork(), thus this is done only on MMU machines: */
192# if !ENABLE_PLATFORM_MINGW32 /* and then only if not on Microsoft Windows */
193 if (APPLET_IS_NOEXEC(a)) {
194 fflush_all();
195 rc = fork();
196 if (rc) /* parent or error */
197 return wait4pid(rc);
198
199 /* child */
200 /* reset some state and run without execing */
201
202 /* msg_eol = "\n"; - no caller needs this reinited yet */
203 logmode = LOGMODE_STDIO;
204 /* die_func = NULL; - needed if the caller is a shell,
205 * init, or a NOFORK applet. But none of those call us
206 * as of yet (and that should probably always stay true).
207 */
208 /* xfunc_error_retval and applet_name are init by: */
209 run_applet_no_and_exit(a, argv);
198 } 210 }
199# if BB_MMU && !ENABLE_PLATFORM_MINGW32 211# endif
200 /* MMU only */
201 /* a->noexec is true */
202 rc = fork();
203 if (rc) /* parent or error */
204 return wait4pid(rc);
205 /* child */
206 xfunc_error_retval = EXIT_FAILURE;
207 run_applet_no_and_exit(a, argv);
208# endif 212# endif
209 } 213 }
210#endif /* FEATURE_PREFER_APPLETS */ 214#endif /* FEATURE_PREFER_APPLETS */