Fix: os/proc-wait

As discused over gitter, `WIFSIGNALED` macro must be checked before one
uses the WTERMSIG macro. This change reflects that necessity and adds a
final else clause which will panic if no status code could be
determined.
This commit is contained in:
llmII 2024-02-12 23:06:08 -06:00
parent 431ecd3d1a
commit 7e94c091eb
No known key found for this signature in database
GPG Key ID: 29C7645EC3EEA0EE
1 changed files with 4 additions and 1 deletions

View File

@ -505,8 +505,11 @@ static int proc_get_status(JanetProc *proc) {
status = WEXITSTATUS(status);
} else if (WIFSTOPPED(status)) {
status = WSTOPSIG(status) + 128;
} else {
} else if (WIFSIGNALED(status)){
status = WTERMSIG(status) + 128;
} else {
/* Could possibly return -1 but for now, just panic */
janet_panicf("Undefined status code for process termination, %d.", status);
}
return status;
}