diff options
author | Pascal Bellard <pascal.bellard@ads-lu.com> | 2010-07-04 15:32:38 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-07-04 15:32:38 +0200 |
commit | 926031b7640bf5aad2ffcd54b096911743a47d97 (patch) | |
tree | 093e0e1bab2c905a97c5880e4942e2000ada7e72 /networking | |
parent | 243d1757d798a0cd43f51eb1db75cc1e81c65732 (diff) | |
download | busybox-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 'networking')
-rw-r--r-- | networking/ftpd.c | 5 | ||||
-rw-r--r-- | networking/ifupdown.c | 8 | ||||
-rw-r--r-- | networking/inetd.c | 2 | ||||
-rw-r--r-- | networking/nc.c | 6 |
4 files changed, 7 insertions, 14 deletions
diff --git a/networking/ftpd.c b/networking/ftpd.c index c63b9319e..e8cae0a36 100644 --- a/networking/ftpd.c +++ b/networking/ftpd.c | |||
@@ -632,10 +632,7 @@ popen_ls(const char *opt) | |||
632 | xpiped_pair(outfd); | 632 | xpiped_pair(outfd); |
633 | 633 | ||
634 | /*fflush_all(); - so far we dont use stdio on output */ | 634 | /*fflush_all(); - so far we dont use stdio on output */ |
635 | pid = BB_MMU ? fork() : vfork(); | 635 | pid = BB_MMU ? xfork() : xvfork(); |
636 | if (pid < 0) | ||
637 | bb_perror_msg_and_die(BB_MMU ? "fork" : "vfork"); | ||
638 | |||
639 | if (pid == 0) { | 636 | if (pid == 0) { |
640 | /* child */ | 637 | /* child */ |
641 | #if !BB_MMU | 638 | #if !BB_MMU |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 1bab2c5cb..69c56e879 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -1041,12 +1041,10 @@ static int popen2(FILE **in, FILE **out, char *command, char *param) | |||
1041 | xpiped_pair(outfd); | 1041 | xpiped_pair(outfd); |
1042 | 1042 | ||
1043 | fflush_all(); | 1043 | fflush_all(); |
1044 | pid = vfork(); | 1044 | pid = xvfork(); |
1045 | 1045 | ||
1046 | switch (pid) { | 1046 | if (pid == 0) { |
1047 | case -1: /* failure */ | 1047 | /* Child */ |
1048 | bb_perror_msg_and_die("vfork"); | ||
1049 | case 0: /* child */ | ||
1050 | /* NB: close _first_, then move fds! */ | 1048 | /* NB: close _first_, then move fds! */ |
1051 | close(infd.wr); | 1049 | close(infd.wr); |
1052 | close(outfd.rd); | 1050 | close(outfd.rd); |
diff --git a/networking/inetd.c b/networking/inetd.c index 2b0e0069e..7030062b6 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -1271,7 +1271,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv) | |||
1271 | pid = vfork(); | 1271 | pid = vfork(); |
1272 | 1272 | ||
1273 | if (pid < 0) { /* fork error */ | 1273 | if (pid < 0) { /* fork error */ |
1274 | bb_perror_msg("fork"); | 1274 | bb_perror_msg("vfork"+1); |
1275 | sleep(1); | 1275 | sleep(1); |
1276 | restore_sigmask(&omask); | 1276 | restore_sigmask(&omask); |
1277 | maybe_close(accepted_fd); | 1277 | maybe_close(accepted_fd); |
diff --git a/networking/nc.c b/networking/nc.c index 5fd8bd759..0dacaf117 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -216,10 +216,8 @@ int nc_main(int argc, char **argv) | |||
216 | if (execparam) { | 216 | if (execparam) { |
217 | pid_t pid; | 217 | pid_t pid; |
218 | /* With more than one -l, repeatedly act as server */ | 218 | /* With more than one -l, repeatedly act as server */ |
219 | if (do_listen > 1 && (pid = vfork()) != 0) { | 219 | if (do_listen > 1 && (pid = xvfork()) != 0) { |
220 | /* parent or error */ | 220 | /* parent */ |
221 | if (pid < 0) | ||
222 | bb_perror_msg_and_die("vfork"); | ||
223 | /* prevent zombies */ | 221 | /* prevent zombies */ |
224 | signal(SIGCHLD, SIG_IGN); | 222 | signal(SIGCHLD, SIG_IGN); |
225 | close(cfd); | 223 | close(cfd); |