Skip to content

Commit

Permalink
Custom error message when subprocess exits with signal 9 on mac
Browse files Browse the repository at this point in the history
This will hopefully help people who run into #210 in future.
  • Loading branch information
davidlattimore committed Jan 15, 2022
1 parent 3a6d79e commit 338e8d0
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions evcxr/src/child_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,25 @@ impl ChildProcess {
content.push('\n');
}
Error::ChildProcessTerminated(match self.process.wait() {
Ok(exit_status) => format!(
"{}Child process terminated with status: {}",
content, exit_status
),
Ok(exit_status) => {
#[cfg(target_os = "macos")]
{
use std::os::unix::process::ExitStatusExt;
if Some(9) == exit_status.signal() {
return Error::ChildProcessTerminated(
"Subprocess terminated with signal 9. This is known \
to happen when evcxr is installed via a Homebrew shell \
under emulation. Try installing rustup and evcxr without \
using Homebrew and see if that helps."
.to_owned(),
);
}
}
format!(
"{}Child process terminated with status: {}",
content, exit_status
)
}
Err(wait_error) => format!("Child process didn't start: {}", wait_error),
})
}
Expand Down

0 comments on commit 338e8d0

Please sign in to comment.