mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +00:00
Shell: Handle the case where the child we're waiting for doesn't exist
Normally, this should not happen, as the child should stay around until we do a waitid on it.
This commit is contained in:
parent
e91dd14fab
commit
dec27e5e6f
1 changed files with 10 additions and 0 deletions
|
@ -78,6 +78,16 @@ int main(int argc, char** argv)
|
|||
for (auto& job : jobs) {
|
||||
int wstatus = 0;
|
||||
auto child_pid = waitpid(job.value->pid(), &wstatus, WNOHANG);
|
||||
if (child_pid < 0) {
|
||||
if (errno == ECHILD) {
|
||||
// The child process went away before we could process its death, just assume it exited all ok.
|
||||
// FIXME: This should never happen, the child should stay around until we do the waitpid above.
|
||||
dbg() << "Child process gone, cannot get exit code for " << job.key;
|
||||
child_pid = job.value->pid();
|
||||
} else {
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
#ifndef __serenity__
|
||||
if (child_pid == 0) {
|
||||
// Linux: if child didn't "change state", but existed.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue