mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 00:10:27 +00:00
Fixes #316: os/execute should return non-zero on signals
Behave more like shells, and catch segfaults.
This commit is contained in:
parent
b0d8369534
commit
3b5183a74e
@ -401,7 +401,16 @@ static Janet os_execute(int32_t argc, Janet *argv) {
|
||||
}
|
||||
|
||||
os_execute_cleanup(envp, child_argv);
|
||||
return janet_wrap_integer(WEXITSTATUS(status));
|
||||
/* Use POSIX shell semantics for interpreting signals */
|
||||
int ret;
|
||||
if (WIFEXITED(status)) {
|
||||
ret = WEXITSTATUS(status);
|
||||
} else if (WIFSTOPPED(status)) {
|
||||
ret = WSTOPSIG(status) + 128;
|
||||
} else {
|
||||
ret = WTERMSIG(status) + 128;
|
||||
}
|
||||
return janet_wrap_integer(ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user