diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-05-27 20:45:59 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-05-27 20:45:59 +0000 |
commit | d130973f349d70571e517c362d480ebcfab936bc (patch) | |
tree | ec5aa05273556dcf23d44e341a312cc3968e170d | |
parent | 82ab3d7c3e65998e0b033347072ee32cf5d61b42 (diff) | |
download | busybox-w32-d130973f349d70571e517c362d480ebcfab936bc.tar.gz busybox-w32-d130973f349d70571e517c362d480ebcfab936bc.tar.bz2 busybox-w32-d130973f349d70571e517c362d480ebcfab936bc.zip |
Put this back the way it was. I misunderstood what vodz was doing.
-rw-r--r-- | libbb/run_parts.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/libbb/run_parts.c b/libbb/run_parts.c index 1cd13f218..58645660b 100644 --- a/libbb/run_parts.c +++ b/libbb/run_parts.c | |||
@@ -83,37 +83,31 @@ extern int run_parts(char **args, const unsigned char test_mode) | |||
83 | if (test_mode & 1) { | 83 | if (test_mode & 1) { |
84 | puts(filename); | 84 | puts(filename); |
85 | } else { | 85 | } else { |
86 | pid_t pid, wpid; | 86 | /* exec_errno is common vfork variable */ |
87 | volatile int exec_errno = 0; | ||
87 | int result; | 88 | int result; |
89 | int pid; | ||
88 | 90 | ||
89 | if ((pid = vfork()) < 0) { | 91 | if ((pid = vfork()) < 0) { |
90 | bb_perror_msg_and_die("failed to fork"); | 92 | bb_perror_msg_and_die("failed to fork"); |
91 | } else if (pid==0) { | 93 | } else if (!pid) { |
94 | args[0] = filename; | ||
92 | execv(filename, args); | 95 | execv(filename, args); |
96 | exec_errno = errno; | ||
93 | _exit(1); | 97 | _exit(1); |
94 | } | 98 | } |
95 | 99 | ||
96 | /* Wait for the child process to exit. Since we use vfork | 100 | waitpid(pid, &result, 0); |
97 | * we shouldn't actually have to do any waiting... */ | 101 | if(exec_errno) { |
98 | wpid = wait(&result); | 102 | errno = exec_errno; |
99 | while (wpid > 0) { | 103 | bb_perror_msg_and_die("failed to exec %s", filename); |
100 | /* Find out who died, make sure it is the right process */ | 104 | } |
101 | if (pid == wpid) { | 105 | if (WIFEXITED(result) && WEXITSTATUS(result)) { |
102 | if (WIFEXITED(result) && WEXITSTATUS(result)) { | 106 | bb_perror_msg("%s exited with return code %d", filename, WEXITSTATUS(result)); |
103 | bb_perror_msg("%s exited with return code %d", filename, WEXITSTATUS(result)); | 107 | exitstatus = 1; |
104 | exitstatus = 1; | 108 | } else if (WIFSIGNALED(result)) { |
105 | } else if (WIFSIGNALED(result) && WIFSIGNALED(result)) { | 109 | bb_perror_msg("%s exited because of uncaught signal %d", filename, WTERMSIG(result)); |
106 | int sig; | 110 | exitstatus = 1; |
107 | sig = WTERMSIG(result); | ||
108 | bb_perror_msg("%s exited because of uncaught signal %d (%s)", | ||
109 | filename, sig, u_signal_names(0, &sig, 1)); | ||
110 | exitstatus = 1; | ||
111 | } | ||
112 | break; | ||
113 | } else { | ||
114 | /* Just in case some _other_ random child process exits */ | ||
115 | wpid = wait(&result); | ||
116 | } | ||
117 | } | 111 | } |
118 | } | 112 | } |
119 | } | 113 | } |