Skip to content

Commit 3e6a742

Browse files
committed
update exit codes
1 parent 7041095 commit 3e6a742

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

analysis/benchmarks/rosetta

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 395e4f1415794ed48cc4925f189e831e6cb82e43

kklib/src/os.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,15 @@ kk_decl_export int kk_os_run_system(kk_string_t cmd, kk_context_t* ctx) {
648648
}
649649
#else
650650
kk_with_string_as_qutf8_borrow(cmd, ccmd, ctx) {
651-
exitcode = system(ccmd);
651+
int status = system(ccmd);
652+
if (WIFEXITED(status)) {
653+
exitcode = WEXITSTATUS(status);
654+
} else if (WIFSIGNALED(status)) {
655+
exitcode = -WTERMSIG(status); // Like Haskell, return negative code for signal termination
656+
} else {
657+
// Technically WIFSTOPPED(status) can happen, but only if the process is being traced, or the call was done with WUNTRACED.
658+
kk_fatal_error(EINVAL, "kk_os_run_system: unexpected termination");
659+
}
652660
}
653661
#endif
654662
kk_string_drop(cmd, ctx);

0 commit comments

Comments
 (0)