Skip to content

Commit

Permalink
Make signal exit format more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOnlyMrCat committed Apr 17, 2022
1 parent 758f6c4 commit 83726fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,18 @@ pub fn process_finish(output_stream: &StandardStream, status: &ProcessExit) {
let sigstr_ptr = unsafe { strsignal(signal as std::os::raw::c_int) };

if sigstr_ptr.is_null() {
format!("signal {}", signal)
format!(
"signal {}{}",
signal,
if core { " - core dumped" } else { "" }
)
} else {
// SAFETY: The string returned from `strsignal` is valid until the next call to strsignal
// SAFETY: The string returned from `strsignal` is valid until our next call to strsignal
// and has been verified to be non-null. The string returned by `strsignal` is null-terminated.
let sigstr = unsafe { CStr::from_ptr(sigstr_ptr) };
format!(
"signal {signal} ({}){}",
"signal {} ({}){}",
signal,
sigstr.to_string_lossy(),
if core { " - core dumped" } else { "" }
)
Expand Down
3 changes: 1 addition & 2 deletions src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,7 @@ impl From<StdioRepr> for Stdio {
StdioRepr::Fd(fd) => {
use std::os::unix::io::FromRawFd;
unsafe {
// SAFETY: Umm, not sure how to enforce this, to be honest.
// I'll deal with it later
// SAFETY: Not currently enforced. Replace with OwnedFd and OwnedHandle when #87074 is stable
Stdio::from_raw_fd(fd)
}
}
Expand Down

0 comments on commit 83726fa

Please sign in to comment.