Skip to content

Commit

Permalink
Unrolled build for rust-lang#121554
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#121554 - Enselic:sigaction, r=oli-obk

Don't unnecessarily change `SIGPIPE` disposition in `unix_sigpipe` tests

In `auxiliary/sigpipe-utils.rs`, all we want to know is the current `SIGPIPE` disposition. We should not change it. So use `libc::sigaction` instead of `libc::signal`. That way we can also remove the code that restores it.

Part of rust-lang#97889.
  • Loading branch information
rust-timer authored Feb 26, 2024
2 parents dc00e8c + f5b9eaf commit 1db9bcc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ pub fn assert_sigpipe_handler(expected_handler: SignalHandler) {
target_os = "android",
)))]
{
let prev = unsafe { libc::signal(libc::SIGPIPE, libc::SIG_IGN) };
let actual = unsafe {
let mut actual: libc::sigaction = std::mem::zeroed();
libc::sigaction(libc::SIGPIPE, std::ptr::null(), &mut actual);
actual.sa_sigaction
};

let expected = match expected_handler {
SignalHandler::Ignore => libc::SIG_IGN,
SignalHandler::Default => libc::SIG_DFL,
};
assert_eq!(prev, expected, "expected sigpipe value matches actual value");

// Unlikely to matter, but restore the old value anyway
unsafe {
libc::signal(libc::SIGPIPE, prev);
};
assert_eq!(actual, expected, "actual and expected SIGPIPE disposition differs");
}
}

0 comments on commit 1db9bcc

Please sign in to comment.