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.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index d25693917..286ee2678 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -115,11 +115,27 @@ int spawn_and_wait(char **argv)
char **pp = argv;
while (*++pp)
argc++;
-#ifdef BB_NOMMU
- return a->main(argc, argv);
-#else
+#ifndef BB_NOMMU
if (a->nofork)
- return a->main(argc, argv);
+#endif
+ {
+ int old_sleep = die_sleep;
+ die_sleep = -1; /* special flag */
+ /* sleep_and_die() checks for it */
+ rc = setjmp(die_jmp);
+ if (!rc) {
+ const struct BB_applet *old_a = current_applet;
+ current_applet = a;
+ applet_name = a->name;
+// what else should we save/restore?
+ rc = a->main(argc, argv);
+ current_applet = old_a;
+ applet_name = old_a->name;
+ }
+ die_sleep = old_sleep;
+ return rc;
+ }
+#ifndef BB_NOMMU /* MMU only */
/* a->noexec is true */
rc = fork();
if (rc)
@@ -135,6 +151,7 @@ int spawn_and_wait(char **argv)
return wait4pid(rc);
}
+
#if 0 //ndef BB_NOMMU
// Die with an error message if we can't daemonize.
void xdaemon(int nochdir, int noclose)