nc/wrappers/
sigaction.rs

1// Copyright (c) 2024 Xu Shaohua <shaohua@biofan.org>. All rights reserved.
2// Use of this source is governed by Apache-2.0 License that can be found
3// in the LICENSE file.
4
5#![allow(clippy::module_name_repetitions)]
6
7use crate::{sigaction_t, sighandler_t, SA_RESTART};
8
9#[cfg(nc_has_sa_restorer)]
10#[inline]
11pub fn new_sigaction(handler: fn(i32)) -> sigaction_t {
12    sigaction_t {
13        sa_handler: handler as sighandler_t,
14        sa_flags: SA_RESTART | crate::SA_RESTORER,
15        sa_restorer: crate::restore::get_sa_restorer(),
16        ..sigaction_t::default()
17    }
18}
19
20#[cfg(not(nc_has_sa_restorer))]
21#[inline]
22pub fn new_sigaction(handler: fn(i32)) -> sigaction_t {
23    sigaction_t {
24        sa_handler: handler as sighandler_t,
25        sa_flags: SA_RESTART,
26        ..sigaction_t::default()
27    }
28}