diff --git a/crates/nu-protocol/src/errors/shell_error.rs b/crates/nu-protocol/src/errors/shell_error.rs index a8ca52142c..e201915fcf 100644 --- a/crates/nu-protocol/src/errors/shell_error.rs +++ b/crates/nu-protocol/src/errors/shell_error.rs @@ -876,6 +876,21 @@ pub enum ShellError { span: Span, }, + #[cfg(unix)] + /// An I/O operation failed. + /// + /// ## Resolution + /// + /// This is a generic error. Refer to the specific error message for further details. + #[error("program coredump error")] + #[diagnostic(code(nu::shell::coredump_error))] + CoredumpErrorSpanned { + msg: String, + signal: i32, + #[label("{msg}")] + span: Span, + }, + /// Tried to `cd` to a path that isn't a directory. /// /// ## Resolution diff --git a/crates/nu-protocol/src/process/child.rs b/crates/nu-protocol/src/process/child.rs index cc74b40fc1..08da7e704c 100644 --- a/crates/nu-protocol/src/process/child.rs +++ b/crates/nu-protocol/src/process/child.rs @@ -23,7 +23,21 @@ impl ExitStatusFuture { ExitStatusFuture::Finished(Err(err)) => Err(err.as_ref().clone()), ExitStatusFuture::Running(receiver) => { let code = match receiver.recv() { - Ok(Ok(status)) => Ok(status), + Ok(Ok(status)) => { + #[cfg(unix)] + if let ExitStatus::Signaled { + signal, + core_dumped: true, + } = status + { + return Err(ShellError::CoredumpErrorSpanned { + msg: format!("coredump detected. received signal: {signal}"), + signal, + span, + }); + } + Ok(status) + } Ok(Err(err)) => Err(ShellError::IOErrorSpanned { msg: format!("failed to get exit code: {err:?}"), span,