Skip to content

Commit

Permalink
Rollup merge of rust-lang#133970 - xingxue-ibm:sigaction, r=nnethercote
Browse files Browse the repository at this point in the history
[AIX] Replace sa_sigaction with sa_union.__su_sigaction for AIX

On AIX, the `sa_sigaction` member of `struct sigaction` is accessed as the union member `sa_union.__su_sigaction`.
  • Loading branch information
fmease authored Dec 10, 2024
2 parents 0981ba2 + 3109f07 commit 6ffeaa9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ fn start(argc: isize, argv: *const *const u8) -> isize {
let actual = unsafe {
let mut actual: libc::sigaction = std::mem::zeroed();
libc::sigaction(libc::SIGPIPE, std::ptr::null(), &mut actual);
actual.sa_sigaction
#[cfg(not(target_os = "aix"))]
{
actual.sa_sigaction
}
#[cfg(target_os = "aix")]
{
actual.sa_union.__su_sigaction as libc::sighandler_t
}
};

assert_eq!(actual, expected, "actual and expected SIGPIPE disposition in child differs");
Expand Down
9 changes: 8 additions & 1 deletion tests/ui/runtime/on-broken-pipe/auxiliary/sigpipe-utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ pub fn assert_sigpipe_handler(expected_handler: SignalHandler) {
let actual = unsafe {
let mut actual: libc::sigaction = std::mem::zeroed();
libc::sigaction(libc::SIGPIPE, std::ptr::null(), &mut actual);
actual.sa_sigaction
#[cfg(not(target_os = "aix"))]
{
actual.sa_sigaction
}
#[cfg(target_os = "aix")]
{
actual.sa_union.__su_sigaction as libc::sighandler_t
}
};

let expected = match expected_handler {
Expand Down
9 changes: 8 additions & 1 deletion tests/ui/runtime/signal-alternate-stack-cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ fn main() {
// Install signal handler that runs on alternate signal stack.
let mut action: sigaction = std::mem::zeroed();
action.sa_flags = (SA_ONSTACK | SA_SIGINFO) as _;
action.sa_sigaction = signal_handler as sighandler_t;
#[cfg(not(target_os = "aix"))]
{
action.sa_sigaction = signal_handler as sighandler_t;
}
#[cfg(target_os = "aix")]
{
action.sa_union.__su_sigaction = signal_handler as sighandler_t;
}
sigaction(SIGWINCH, &action, std::ptr::null_mut());

// Send SIGWINCH on exit.
Expand Down

0 comments on commit 6ffeaa9

Please sign in to comment.