*: 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>
diff --git a/networking/ftpd.c b/networking/ftpd.c
index c63b931..e8cae0a 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -632,10 +632,7 @@
xpiped_pair(outfd);
/*fflush_all(); - so far we dont use stdio on output */
- pid = BB_MMU ? fork() : vfork();
- if (pid < 0)
- bb_perror_msg_and_die(BB_MMU ? "fork" : "vfork");
-
+ pid = BB_MMU ? xfork() : xvfork();
if (pid == 0) {
/* child */
#if !BB_MMU
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 1bab2c5..69c56e8 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1041,12 +1041,10 @@
xpiped_pair(outfd);
fflush_all();
- pid = vfork();
+ pid = xvfork();
- switch (pid) {
- case -1: /* failure */
- bb_perror_msg_and_die("vfork");
- case 0: /* child */
+ if (pid == 0) {
+ /* Child */
/* NB: close _first_, then move fds! */
close(infd.wr);
close(outfd.rd);
diff --git a/networking/inetd.c b/networking/inetd.c
index 2b0e006..7030062 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1271,7 +1271,7 @@
pid = vfork();
if (pid < 0) { /* fork error */
- bb_perror_msg("fork");
+ bb_perror_msg("vfork"+1);
sleep(1);
restore_sigmask(&omask);
maybe_close(accepted_fd);
diff --git a/networking/nc.c b/networking/nc.c
index 5fd8bd7..0dacaf1 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -216,10 +216,8 @@
if (execparam) {
pid_t pid;
/* With more than one -l, repeatedly act as server */
- if (do_listen > 1 && (pid = vfork()) != 0) {
- /* parent or error */
- if (pid < 0)
- bb_perror_msg_and_die("vfork");
+ if (do_listen > 1 && (pid = xvfork()) != 0) {
+ /* parent */
/* prevent zombies */
signal(SIGCHLD, SIG_IGN);
close(cfd);