aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/libbb.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 4b6699f2f..e2a8322b8 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -841,6 +841,19 @@ int bb_execvp(const char *file, char *const argv[]) FAST_FUNC;
841#endif 841#endif
842int BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC; 842int BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC;
843 843
844/* xvfork() can't be a _function_, return after vfork mangles stack
845 * in the parent. It must be a macro. */
846#define xvfork() \
847({ \
848 pid_t bb__xvfork_pid = vfork(); \
849 if (bb__xvfork_pid < 0) \
850 bb_perror_msg_and_die("vfork"); \
851 bb__xvfork_pid; \
852})
853#if BB_MMU
854pid_t xfork(void) FAST_FUNC;
855#endif
856
844/* NOMMU friendy fork+exec: */ 857/* NOMMU friendy fork+exec: */
845pid_t spawn(char **argv) FAST_FUNC; 858pid_t spawn(char **argv) FAST_FUNC;
846pid_t xspawn(char **argv) FAST_FUNC; 859pid_t xspawn(char **argv) FAST_FUNC;
@@ -886,7 +899,7 @@ int run_nofork_applet_prime(struct nofork_save_area *old, int applet_no, char **
886 * Both of the above will redirect fd 0,1,2 to /dev/null and drop ctty 899 * Both of the above will redirect fd 0,1,2 to /dev/null and drop ctty
887 * (will do setsid()). 900 * (will do setsid()).
888 * 901 *
889 * fork_or_rexec(argv) = bare-bones "fork" on MMU, 902 * fork_or_rexec(argv) = bare-bones fork on MMU,
890 * "vfork + re-exec ourself" on NOMMU. No fd redirection, no setsid(). 903 * "vfork + re-exec ourself" on NOMMU. No fd redirection, no setsid().
891 * On MMU ignores argv. 904 * On MMU ignores argv.
892 * 905 *
@@ -902,19 +915,19 @@ enum {
902 DAEMON_ONLY_SANITIZE = 8, /* internal use */ 915 DAEMON_ONLY_SANITIZE = 8, /* internal use */
903}; 916};
904#if BB_MMU 917#if BB_MMU
905 pid_t fork_or_rexec(void) FAST_FUNC;
906 enum { re_execed = 0 }; 918 enum { re_execed = 0 };
907# define fork_or_rexec(argv) fork_or_rexec() 919# define fork_or_rexec(argv) xfork()
908# define bb_daemonize_or_rexec(flags, argv) bb_daemonize_or_rexec(flags) 920# define bb_daemonize_or_rexec(flags, argv) bb_daemonize_or_rexec(flags)
909# define bb_daemonize(flags) bb_daemonize_or_rexec(flags, bogus) 921# define bb_daemonize(flags) bb_daemonize_or_rexec(flags, bogus)
910#else 922#else
923 extern bool re_execed;
911 void re_exec(char **argv) NORETURN FAST_FUNC; 924 void re_exec(char **argv) NORETURN FAST_FUNC;
912 pid_t fork_or_rexec(char **argv) FAST_FUNC; 925 pid_t fork_or_rexec(char **argv) FAST_FUNC;
913 extern bool re_execed;
914 int BUG_fork_is_unavailable_on_nommu(void) FAST_FUNC; 926 int BUG_fork_is_unavailable_on_nommu(void) FAST_FUNC;
915 int BUG_daemon_is_unavailable_on_nommu(void) FAST_FUNC; 927 int BUG_daemon_is_unavailable_on_nommu(void) FAST_FUNC;
916 void BUG_bb_daemonize_is_unavailable_on_nommu(void) FAST_FUNC; 928 void BUG_bb_daemonize_is_unavailable_on_nommu(void) FAST_FUNC;
917# define fork() BUG_fork_is_unavailable_on_nommu() 929# define fork() BUG_fork_is_unavailable_on_nommu()
930# define xfork() BUG_fork_is_unavailable_on_nommu()
918# define daemon(a,b) BUG_daemon_is_unavailable_on_nommu() 931# define daemon(a,b) BUG_daemon_is_unavailable_on_nommu()
919# define bb_daemonize(a) BUG_bb_daemonize_is_unavailable_on_nommu() 932# define bb_daemonize(a) BUG_bb_daemonize_is_unavailable_on_nommu()
920#endif 933#endif