aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-01 15:59:42 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-01 15:59:42 +0000
commit82604e973085f91f1b99cacea08963d0d1468084 (patch)
tree2de05bb2a6943ca6be0cc46f36e5fb07099aef40 /networking
parentb111917972c1398ef96ef2d388c6c4ba57a8e9f7 (diff)
downloadbusybox-w32-82604e973085f91f1b99cacea08963d0d1468084.tar.gz
busybox-w32-82604e973085f91f1b99cacea08963d0d1468084.tar.bz2
busybox-w32-82604e973085f91f1b99cacea08963d0d1468084.zip
revert last two commits. vfork cannot be used in subroutine,
it trashes stack on return
Diffstat (limited to 'networking')
-rw-r--r--networking/ifupdown.c7
-rw-r--r--networking/inetd.c2
-rw-r--r--networking/sendmail.c11
3 files changed, 16 insertions, 4 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 8caff3f4d..c12391863 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1008,9 +1008,12 @@ static int popen2(FILE **in, FILE **out, char *command, char *param)
1008 xpiped_pair(outfd); 1008 xpiped_pair(outfd);
1009 1009
1010 fflush(NULL); 1010 fflush(NULL);
1011 pid = xvfork(); 1011 pid = vfork();
1012 1012
1013 if (pid == 0) { /* child */ 1013 switch (pid) {
1014 case -1: /* failure */
1015 bb_perror_msg_and_die("vfork");
1016 case 0: /* child */
1014 /* NB: close _first_, then move fds! */ 1017 /* NB: close _first_, then move fds! */
1015 close(infd.wr); 1018 close(infd.wr);
1016 close(outfd.rd); 1019 close(outfd.rd);
diff --git a/networking/inetd.c b/networking/inetd.c
index 0028078db..08c09953b 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1303,7 +1303,7 @@ int inetd_main(int argc ATTRIBUTE_UNUSED, char **argv)
1303 pid = vfork(); 1303 pid = vfork();
1304 1304
1305 if (pid < 0) { /* fork error */ 1305 if (pid < 0) { /* fork error */
1306 bb_perror_msg(BB_MMU ? "vfork" + 1 : "vfork"); 1306 bb_perror_msg("fork");
1307 sleep(1); 1307 sleep(1);
1308 restore_sigmask(&omask); 1308 restore_sigmask(&omask);
1309 maybe_close(accepted_fd); 1309 maybe_close(accepted_fd);
diff --git a/networking/sendmail.c b/networking/sendmail.c
index c195cc021..1c23ca290 100644
--- a/networking/sendmail.c
+++ b/networking/sendmail.c
@@ -120,6 +120,15 @@ static void signal_handler(int signo)
120#undef err 120#undef err
121} 121}
122 122
123/* libbb candidate */
124static pid_t vfork_or_die(void)
125{
126 pid_t pid = vfork();
127 if (pid < 0)
128 bb_perror_msg_and_die("vfork");
129 return pid;
130}
131
123static void launch_helper(const char **argv) 132static void launch_helper(const char **argv)
124{ 133{
125 // setup vanilla unidirectional pipes interchange 134 // setup vanilla unidirectional pipes interchange
@@ -128,7 +137,7 @@ static void launch_helper(const char **argv)
128 137
129 xpipe(pipes); 138 xpipe(pipes);
130 xpipe(pipes+2); 139 xpipe(pipes+2);
131 helper_pid = xvfork(); 140 helper_pid = vfork_or_die();
132 idx = (!helper_pid) * 2; 141 idx = (!helper_pid) * 2;
133 xdup2(pipes[idx], STDIN_FILENO); 142 xdup2(pipes[idx], STDIN_FILENO);
134 xdup2(pipes[3-idx], STDOUT_FILENO); 143 xdup2(pipes[3-idx], STDOUT_FILENO);