Replace sa_sigaction with sa_union.__su_sigaction for AIX.

This commit is contained in:
Xing Xue 2024-12-06 12:51:59 -05:00
parent bc145cec45
commit 3109f07d85
3 changed files with 24 additions and 3 deletions

View file

@ -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");

View file

@ -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 {

View file

@ -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.