summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPascal Bellard <pascal.bellard@ads-lu.com>2010-07-04 15:32:38 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-07-04 15:32:38 +0200
commit926031b7640bf5aad2ffcd54b096911743a47d97 (patch)
tree093e0e1bab2c905a97c5880e4942e2000ada7e72 /include
parent243d1757d798a0cd43f51eb1db75cc1e81c65732 (diff)
downloadbusybox-w32-926031b7640bf5aad2ffcd54b096911743a47d97.tar.gz
busybox-w32-926031b7640bf5aad2ffcd54b096911743a47d97.tar.bz2
busybox-w32-926031b7640bf5aad2ffcd54b096911743a47d97.zip
*: introduce and use xfork() and xvfork()
function old new delta launch_helper 170 169 -1 setup_heredoc 312 302 -10 handle_dir_common 367 354 -13 expand_vars_to_list 2456 2443 -13 open_transformer 89 74 -15 data_extract_to_command 439 423 -16 do_ipaddr 1406 1389 -17 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-85) Total: -85 bytes Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
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