summaryrefslogtreecommitdiff
path: root/libbb/vfork_daemon_rexec.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-04-11 07:04:23 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-04-11 07:04:23 +0000
commit473dae080a8a0089d5d619a56d8943d131aa451e (patch)
tree29763aae84d2c9336d9f34a5dc02c024285af60e /libbb/vfork_daemon_rexec.c
parentf1a7141cfcacf606ae321faa58c45617045460fe (diff)
downloadbusybox-w32-473dae080a8a0089d5d619a56d8943d131aa451e.tar.gz
busybox-w32-473dae080a8a0089d5d619a56d8943d131aa451e.tar.bz2
busybox-w32-473dae080a8a0089d5d619a56d8943d131aa451e.zip
add more convenient defines for [NO]MMU:
"#ifndef BB_NOMMU" is a double negative
Diffstat (limited to 'libbb/vfork_daemon_rexec.c')
-rw-r--r--libbb/vfork_daemon_rexec.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index 64952225d..281ead4dc 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -107,15 +107,15 @@ int spawn_and_wait(char **argv)
107 const struct bb_applet *a = find_applet_by_name(argv[0]); 107 const struct bb_applet *a = find_applet_by_name(argv[0]);
108 108
109 if (a && (a->nofork 109 if (a && (a->nofork
110#ifndef BB_NOMMU 110#if BB_MMU
111 || a->noexec /* NOEXEC cannot be used on NOMMU */ 111 || a->noexec /* NOEXEC trick needs fork() */
112#endif 112#endif
113 )) { 113 )) {
114 int argc = 1; 114 int argc = 1;
115 char **pp = argv; 115 char **pp = argv;
116 while (*++pp) 116 while (*++pp)
117 argc++; 117 argc++;
118#ifndef BB_NOMMU 118#if BB_MMU
119 if (a->nofork) 119 if (a->nofork)
120#endif 120#endif
121 { 121 {
@@ -136,7 +136,7 @@ int spawn_and_wait(char **argv)
136 applet_name = a->name; 136 applet_name = a->name;
137// what else should we save/restore? 137// what else should we save/restore?
138// TODO: what if applet will mangle argv vector? 138// TODO: what if applet will mangle argv vector?
139// xargs needs argv untouched because it frees the vector! 139// xargs needs argv untouched because it frees argv[i]!
140// shouldn't we pass a copy? 140// shouldn't we pass a copy?
141 rc = a->main(argc, argv); 141 rc = a->main(argc, argv);
142 current_applet = old_a; 142 current_applet = old_a;
@@ -152,29 +152,25 @@ int spawn_and_wait(char **argv)
152 option_mask32 = old_m; 152 option_mask32 = old_m;
153 return rc; 153 return rc;
154 } 154 }
155#ifndef BB_NOMMU /* MMU only */ 155#if BB_MMU
156 /* MMU only */
156 /* a->noexec is true */ 157 /* a->noexec is true */
157 rc = fork(); 158 rc = fork();
158 if (rc) 159 if (rc) /* parent or error */
159 goto w; 160 return wait4pid(rc);
160 /* child */ 161 /* child */
161 xfunc_error_retval = EXIT_FAILURE; 162 xfunc_error_retval = EXIT_FAILURE;
162 current_applet = a; 163 current_applet = a;
163 run_current_applet_and_exit(argc, argv); 164 run_current_applet_and_exit(argc, argv);
164#endif 165#endif
165 } 166 }
167#endif /* FEATURE_PREFER_APPLETS */
166 rc = spawn(argv); 168 rc = spawn(argv);
167#ifndef BB_NOMMU
168 w:
169#endif
170 return wait4pid(rc); 169 return wait4pid(rc);
171#else /* !FEATURE_PREFER_APPLETS */
172 return wait4pid(spawn(argv));
173#endif
174} 170}
175 171
176 172
177#ifdef BB_NOMMU 173#if !BB_MMU
178void forkexit_or_rexec(char **argv) 174void forkexit_or_rexec(char **argv)
179{ 175{
180 pid_t pid; 176 pid_t pid;
@@ -210,7 +206,6 @@ void forkexit_or_rexec(void)
210#define forkexit_or_rexec(argv) forkexit_or_rexec() 206#define forkexit_or_rexec(argv) forkexit_or_rexec()
211#endif 207#endif
212 208
213
214/* Due to a #define in libbb.h on MMU systems we actually have 1 argument - 209/* Due to a #define in libbb.h on MMU systems we actually have 1 argument -
215 * char **argv "vanishes" */ 210 * char **argv "vanishes" */
216void bb_daemonize_or_rexec(int flags, char **argv) 211void bb_daemonize_or_rexec(int flags, char **argv)