mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
Put this back the way it was. I misunderstood what vodz was doing.
This commit is contained in:
parent
82ab3d7c3e
commit
d130973f34
@ -83,37 +83,31 @@ extern int run_parts(char **args, const unsigned char test_mode)
|
|||||||
if (test_mode & 1) {
|
if (test_mode & 1) {
|
||||||
puts(filename);
|
puts(filename);
|
||||||
} else {
|
} else {
|
||||||
pid_t pid, wpid;
|
/* exec_errno is common vfork variable */
|
||||||
|
volatile int exec_errno = 0;
|
||||||
int result;
|
int result;
|
||||||
|
int pid;
|
||||||
|
|
||||||
if ((pid = vfork()) < 0) {
|
if ((pid = vfork()) < 0) {
|
||||||
bb_perror_msg_and_die("failed to fork");
|
bb_perror_msg_and_die("failed to fork");
|
||||||
} else if (pid==0) {
|
} else if (!pid) {
|
||||||
|
args[0] = filename;
|
||||||
execv(filename, args);
|
execv(filename, args);
|
||||||
|
exec_errno = errno;
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for the child process to exit. Since we use vfork
|
waitpid(pid, &result, 0);
|
||||||
* we shouldn't actually have to do any waiting... */
|
if(exec_errno) {
|
||||||
wpid = wait(&result);
|
errno = exec_errno;
|
||||||
while (wpid > 0) {
|
bb_perror_msg_and_die("failed to exec %s", filename);
|
||||||
/* Find out who died, make sure it is the right process */
|
}
|
||||||
if (pid == wpid) {
|
if (WIFEXITED(result) && WEXITSTATUS(result)) {
|
||||||
if (WIFEXITED(result) && WEXITSTATUS(result)) {
|
bb_perror_msg("%s exited with return code %d", filename, WEXITSTATUS(result));
|
||||||
bb_perror_msg("%s exited with return code %d", filename, WEXITSTATUS(result));
|
exitstatus = 1;
|
||||||
exitstatus = 1;
|
} else if (WIFSIGNALED(result)) {
|
||||||
} else if (WIFSIGNALED(result) && WIFSIGNALED(result)) {
|
bb_perror_msg("%s exited because of uncaught signal %d", filename, WTERMSIG(result));
|
||||||
int sig;
|
exitstatus = 1;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user