Get exit code correctly

`status` isn't the exit code of the program - the actual exit code is
shifted left by 8 bits. We can get that with a `WIFEXITED` check to make
sure the exit code exists, followed by `WEXITSTATUS` to retrieve it.
This commit is contained in:
Jackson Wambolt 2024-06-26 04:50:06 +00:00
parent 1f0303cf53
commit 11c9b90551
No known key found for this signature in database
GPG key ID: 76F29A42FEE8811C

View file

@ -1244,7 +1244,13 @@ fn roc_dev_native(
let options = 0;
unsafe { libc::waitpid(pid, &mut status, options) };
break status;
// if `WIFEXITED` returns false, `WEXITSTATUS` will just return junk
break if libc::WIFEXITED(status) {
libc::WEXITSTATUS(status)
} else {
// we don't have an exit code, so we probably shouldn't make one up
0
};
}
ChildProcessMsg::Expect => {
roc_repl_expect::run::render_expects_in_memory(