From d23981e2fb89f5b5c09891a6ca5c42fbd672773f Mon Sep 17 00:00:00 2001 From: Qiu Chaofan Date: Tue, 9 May 2023 12:57:24 +0800 Subject: [PATCH] Support AIX signal action types --- src/unix.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/unix.rs b/src/unix.rs index 857fbc5..df6788b 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -65,7 +65,15 @@ impl State { // Register our sigchld handler let mut new: libc::sigaction = mem::zeroed(); - new.sa_sigaction = sigchld_handler as usize; + + #[cfg(not(target_os = "aix"))] + let set_handler = + |action: &mut libc::sigaction, handler| action.sa_sigaction = handler as usize; + #[cfg(target_os = "aix")] + let set_handler = + |action: &mut libc::sigaction, handler| action.sa_union.__su_sigaction = handler; + set_handler(&mut new, sigchld_handler); + new.sa_flags = libc::SA_NOCLDSTOP | libc::SA_RESTART | libc::SA_SIGINFO; assert_eq!(libc::sigaction(libc::SIGCHLD, &new, &mut state.prev), 0); @@ -256,7 +264,11 @@ extern "C" fn sigchld_handler(signum: c_int, info: *mut libc::siginfo_t, ptr: *m let state = &*STATE; notify(&state.write); + #[cfg(not(target_os = "aix"))] let fnptr = state.prev.sa_sigaction; + #[cfg(target_os = "aix")] + let fnptr = state.prev.sa_union.__su_sigaction as usize; + if fnptr == 0 { return; }