aboutsummaryrefslogtreecommitdiff
path: root/libbb/vfork_daemon_rexec.c
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-04-09 21:35:07 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-04-09 21:35:07 +0000
commitd380c416f4b6b1d9d3ca66df11fc69c85ecbee53 (patch)
treed5c648f583bb2edef25f05c2bed303df3d1a61f6 /libbb/vfork_daemon_rexec.c
parentdb15f9c96ab5d863a1304ae3a9be06b0bcad08be (diff)
downloadbusybox-w32-d380c416f4b6b1d9d3ca66df11fc69c85ecbee53.tar.gz
busybox-w32-d380c416f4b6b1d9d3ca66df11fc69c85ecbee53.tar.bz2
busybox-w32-d380c416f4b6b1d9d3ca66df11fc69c85ecbee53.zip
make xfunctions optionally longjump instead of exit.
use it for making NOFORK more practical. touch: make it a NOFORK applet git-svn-id: svn://busybox.net/trunk/busybox@18376 69ca8d6d-28ef-0310-b511-8ec308f3f277
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)
115 char **pp = argv; 115 char **pp = argv;
116 while (*++pp) 116 while (*++pp)
117 argc++; 117 argc++;
118#ifdef BB_NOMMU 118#ifndef BB_NOMMU
119 return a->main(argc, argv);
120#else
121 if (a->nofork) 119 if (a->nofork)
122 return a->main(argc, argv); 120#endif
121 {
122 int old_sleep = die_sleep;
123 die_sleep = -1; /* special flag */
124 /* sleep_and_die() checks for it */
125 rc = setjmp(die_jmp);
126 if (!rc) {
127 const struct BB_applet *old_a = current_applet;
128 current_applet = a;
129 applet_name = a->name;
130// what else should we save/restore?
131 rc = a->main(argc, argv);
132 current_applet = old_a;
133 applet_name = old_a->name;
134 }
135 die_sleep = old_sleep;
136 return rc;
137 }
138#ifndef BB_NOMMU /* MMU only */
123 /* a->noexec is true */ 139 /* a->noexec is true */
124 rc = fork(); 140 rc = fork();
125 if (rc) 141 if (rc)
@@ -135,6 +151,7 @@ int spawn_and_wait(char **argv)
135 return wait4pid(rc); 151 return wait4pid(rc);
136} 152}
137 153
154
138#if 0 //ndef BB_NOMMU 155#if 0 //ndef BB_NOMMU
139// Die with an error message if we can't daemonize. 156// Die with an error message if we can't daemonize.
140void xdaemon(int nochdir, int noclose) 157void xdaemon(int nochdir, int noclose)