Hi,
The attached patch fixes a compilation error:
undefined reference to `_BUG_bb_daemonize_is_unavailable_on_nommu
and makes start-stop-daemon usable on no-MMU by using bb_daemonize only if
BB_MMU and
emulating it if !BB_MMU.
This is a bit hackish, since after vfork(), the child does all the work and
exec()s the
daemon, rather than execing right away, as the vfork paradigma says. Still I
think this
is better than re-execing start-stop-daemon and only then execing the daemon
itself since
this approach requires removing the -b (or --background) arguments from the
command line,
which is not fun (what if there are several -b options? etc.), and does not
give any
visible benefits.
You may also find some code duplications with the fork_and_reexec functions
(i.e. call to
setsid, dupping /dev/null to 0,1 and 2), but I think this is unavoidable since
all of
these functions either do something slightly different or do not work on no-MMU.
Regards,
Alex
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for
today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow Index: debianutils/start_stop_daemon.c
===================================================================
--- debianutils/start_stop_daemon.c (revision 19242)
+++ debianutils/start_stop_daemon.c (working copy)
@@ -299,7 +299,28 @@
}
*--argv = startas;
if (opt & OPT_BACKGROUND) {
+#if BB_MMU
bb_daemonize(0);
+#else
+ int fd;
+
+ switch (vfork()) {
+ case -1: /* wtf? */
+ bb_perror_msg_and_die("vfork");
+ break;
+ case 0: /* child */
+ break;
+ default: /* parent */
+ exit(0);
+ }
+
+ fd = xopen(bb_dev_null, O_RDWR);
+ setsid();
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ close(fd);
+#endif
}
if (opt & OPT_MAKEPID) {
/* user wants _us_ to make the pidfile */
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox