- /* 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("failed to exec %s", filename);
+ exitstatus = 1;
+ }
+ 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;