aboutsummaryrefslogtreecommitdiff
path: root/libbb/vfork_daemon_rexec.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-04-09 21:35:07 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-04-09 21:35:07 +0000
commit3f3aa2a57dc648ade9083f3b3ad83cce8206b912 (patch)
treed5c648f583bb2edef25f05c2bed303df3d1a61f6 /libbb/vfork_daemon_rexec.c
parentcd7001f7055c3fc2d6298ab9e3befe91e951c652 (diff)
downloadbusybox-3f3aa2a57dc648ade9083f3b3ad83cce8206b912.tar.gz
make xfunctions optionally longjump instead of exit.
use it for making NOFORK more practical. touch: make it a NOFORK applet
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)