diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/libbb.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/include/libbb.h b/include/libbb.h index ff7d3bf1a..32e099b54 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -471,7 +471,9 @@ int bb_execvp(const char *file, char *const argv[]); | |||
471 | pid_t spawn(char **argv); | 471 | pid_t spawn(char **argv); |
472 | pid_t xspawn(char **argv); | 472 | pid_t xspawn(char **argv); |
473 | /* Helpers for daemonization. | 473 | /* Helpers for daemonization. |
474 | * | ||
474 | * bb_daemonize(flags) = daemonize, does not compile on NOMMU | 475 | * bb_daemonize(flags) = daemonize, does not compile on NOMMU |
476 | * | ||
475 | * bb_daemonize_or_rexec(flags, argv) = daemonizes on MMU (and ignores argv), | 477 | * bb_daemonize_or_rexec(flags, argv) = daemonizes on MMU (and ignores argv), |
476 | * rexec's itself on NOMMU with argv passed as command line. | 478 | * rexec's itself on NOMMU with argv passed as command line. |
477 | * Thus bb_daemonize_or_rexec may cause your <applet>_main() to be re-executed | 479 | * Thus bb_daemonize_or_rexec may cause your <applet>_main() to be re-executed |
@@ -482,7 +484,12 @@ pid_t xspawn(char **argv); | |||
482 | * Both of the above will redirect fd 0,1,2 to /dev/null and drop ctty | 484 | * Both of the above will redirect fd 0,1,2 to /dev/null and drop ctty |
483 | * (will do setsid()). | 485 | * (will do setsid()). |
484 | * | 486 | * |
487 | * forkexit_or_rexec(argv) = bare-bones "fork + parent exits" on MMU, | ||
488 | * "vfork + re-exec ourself" on NOMMU. No fd redirection, no setsid(). | ||
489 | * Currently used for openvt. On MMU ignores argv. | ||
490 | * | ||
485 | * Helper for network daemons in foreground mode: | 491 | * Helper for network daemons in foreground mode: |
492 | * | ||
486 | * bb_sanitize_stdio() = make sure that fd 0,1,2 are opened by opening them | 493 | * bb_sanitize_stdio() = make sure that fd 0,1,2 are opened by opening them |
487 | * to /dev/null if they are not. | 494 | * to /dev/null if they are not. |
488 | */ | 495 | */ |
@@ -493,16 +500,16 @@ enum { | |||
493 | DAEMON_ONLY_SANITIZE = 8, /* internal use */ | 500 | DAEMON_ONLY_SANITIZE = 8, /* internal use */ |
494 | }; | 501 | }; |
495 | #ifndef BB_NOMMU | 502 | #ifndef BB_NOMMU |
496 | #define bb_daemonize_or_rexec(flags, argv) bb_daemonize_or_rexec(flags) | 503 | void forkexit_or_rexec(void); |
497 | #define bb_daemonize(flags) bb_daemonize_or_rexec(flags, bogus) | 504 | # define forkexit_or_rexec(argv) forkexit_or_rexec() |
505 | # define bb_daemonize_or_rexec(flags, argv) bb_daemonize_or_rexec(flags) | ||
506 | # define bb_daemonize(flags) bb_daemonize_or_rexec(flags, bogus) | ||
498 | #else | 507 | #else |
499 | extern smallint re_execed; | 508 | void forkexit_or_rexec(char **argv); |
500 | pid_t BUG_fork_is_unavailable_on_nommu(void); | 509 | extern smallint re_execed; |
501 | pid_t BUG_daemon_is_unavailable_on_nommu(void); | 510 | # define fork() BUG_fork_is_unavailable_on_nommu() |
502 | pid_t BUG_bb_daemonize_is_unavailable_on_nommu(void); | 511 | # define daemon(a,b) BUG_daemon_is_unavailable_on_nommu() |
503 | #define fork() BUG_fork_is_unavailable_on_nommu() | 512 | # define bb_daemonize(a) BUG_bb_daemonize_is_unavailable_on_nommu() |
504 | #define daemon(a,b) BUG_daemon_is_unavailable_on_nommu() | ||
505 | #define bb_daemonize(a) BUG_bb_daemonize_is_unavailable_on_nommu() | ||
506 | #endif | 513 | #endif |
507 | void bb_daemonize_or_rexec(int flags, char **argv); | 514 | void bb_daemonize_or_rexec(int flags, char **argv); |
508 | void bb_sanitize_stdio(void); | 515 | void bb_sanitize_stdio(void); |