[BusyBox-cvs] busybox/libbb run_parts.c,1.7,1.8
Erik Andersen
andersen at busybox.net
Tue May 27 20:46:03 UTC 2003
Update of /var/cvs/busybox/libbb
In directory winder:/tmp/cvs-serv25920/libbb
Modified Files:
run_parts.c
Log Message:
Put this back the way it was. I misunderstood what vodz was doing.
Index: run_parts.c
===================================================================
RCS file: /var/cvs/busybox/libbb/run_parts.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- run_parts.c 26 May 2003 18:12:00 -0000 1.7
+++ run_parts.c 27 May 2003 20:45:59 -0000 1.8
@@ -83,37 +83,31 @@
if (test_mode & 1) {
puts(filename);
} else {
- pid_t pid, wpid;
+ /* exec_errno is common vfork variable */
+ volatile int exec_errno = 0;
int result;
+ int pid;
if ((pid = vfork()) < 0) {
bb_perror_msg_and_die("failed to fork");
- } else if (pid==0) {
+ } else if (!pid) {
+ args[0] = filename;
execv(filename, args);
+ exec_errno = errno;
_exit(1);
}
- /* Wait for the child process to exit. Since we use vfork
- * we shouldn't actually have to do any waiting... */
- wpid = wait(&result);
- while (wpid > 0) {
- /* Find out who died, make sure it is the right process */
- if (pid == wpid) {
- if (WIFEXITED(result) && WEXITSTATUS(result)) {
- bb_perror_msg("%s exited with return code %d", filename, WEXITSTATUS(result));
- exitstatus = 1;
- } else if (WIFSIGNALED(result) && WIFSIGNALED(result)) {
- int sig;
- sig = WTERMSIG(result);
- bb_perror_msg("%s exited because of uncaught signal %d (%s)",
- filename, sig, u_signal_names(0, &sig, 1));
- exitstatus = 1;
- }
- break;
- } else {
- /* Just in case some _other_ random child process exits */
- wpid = wait(&result);
- }
+ waitpid(pid, &result, 0);
+ if(exec_errno) {
+ errno = exec_errno;
+ bb_perror_msg_and_die("failed to exec %s", filename);
+ }
+ if (WIFEXITED(result) && WEXITSTATUS(result)) {
+ bb_perror_msg("%s exited with return code %d", filename, WEXITSTATUS(result));
+ exitstatus = 1;
+ } else if (WIFSIGNALED(result)) {
+ bb_perror_msg("%s exited because of uncaught signal %d", filename, WTERMSIG(result));
+ exitstatus = 1;
}
}
}
More information about the busybox-cvs
mailing list