roc dev: report the status code of the child process

This commit is contained in:
Folkert 2023-06-16 20:33:32 +02:00
parent 1646dc4e73
commit 3d3243bfb5
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -1086,14 +1086,20 @@ fn roc_dev_native(
std::process::exit(1)
}
1.. => {
pid @ 1.. => {
let sigchld = Arc::new(AtomicBool::new(false));
signal_hook::flag::register(signal_hook::consts::SIGCHLD, Arc::clone(&sigchld))
.unwrap();
loop {
let exit_code = loop {
match memory.wait_for_child(sigchld.clone()) {
ChildProcessMsg::Terminate => break,
ChildProcessMsg::Terminate => {
let mut status = 0;
let options = 0;
unsafe { libc::waitpid(pid, &mut status, options) };
break status;
}
ChildProcessMsg::Expect => {
roc_repl_expect::run::render_expects_in_memory(
&mut writer,
@ -1121,9 +1127,9 @@ fn roc_dev_native(
memory.reset();
}
}
}
};
std::process::exit(0)
std::process::exit(exit_code)
}
_ => unreachable!(),
}