From 7e94c091eb0bb2a625b6b4788886cef43d7f5ca3 Mon Sep 17 00:00:00 2001 From: llmII Date: Mon, 12 Feb 2024 23:06:08 -0600 Subject: [PATCH] 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. --- src/core/os.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/os.c b/src/core/os.c index 9bc9820f..dcd68a16 100644 --- a/src/core/os.c +++ b/src/core/os.c @@ -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; }