1 /* Copyright (C) 2014-2017 Free Software Foundation, Inc.
3 The GNU C Library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Lesser General Public
5 License as published by the Free Software Foundation; either
6 version 2.1 of the License, or (at your option) any later version.
8 The GNU C Library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Lesser General Public License for more details.
13 You should have received a copy of the GNU Lesser General Public
14 License along with the GNU C Library; if not, see
15 <http://www.gnu.org/licenses/>. */
19 /* The signal used for asynchronous cancelation. */
20 #define SIGCANCEL __SIGRTMIN
22 /* Signal needed for the kernel-supported POSIX timer implementation.
23 We can reuse the cancellation signal since we can distinguish
24 cancellation from timer expirations. */
25 #define SIGTIMER SIGCANCEL
27 /* Signal used to implement the setuid et.al. functions. */
28 #define SIGSETXID (__SIGRTMIN + 1)
30 /* Return if sig is used internally. */
32 __is_internal_signal (int sig
)
34 return (sig
== SIGCANCEL
) || (sig
== SIGTIMER
) || (sig
== SIGSETXID
);
37 /* Remove internal signal from the mask. */
39 __clear_internal_signals (sigset_t
*set
)
41 __sigdelset (set
, SIGCANCEL
);
42 __sigdelset (set
, SIGTIMER
);
43 __sigdelset (set
, SIGSETXID
);
47 ((__sigset_t) { .__val = {[0 ... _SIGSET_NWORDS-1 ] = -1 } })
49 /* Block all signals, including internal ones. */
51 __libc_signal_block_all (sigset_t
*set
)
53 INTERNAL_SYSCALL_DECL (err
);
54 return INTERNAL_SYSCALL (rt_sigprocmask
, err
, 4, SIG_BLOCK
, &SIGALL_SET
,
58 /* Block all application signals (excluding internal ones). */
60 __libc_signal_block_app (sigset_t
*set
)
62 sigset_t allset
= SIGALL_SET
;
63 __clear_internal_signals (&allset
);
64 INTERNAL_SYSCALL_DECL (err
);
65 return INTERNAL_SYSCALL (rt_sigprocmask
, err
, 4, SIG_BLOCK
, &allset
, set
,
69 /* Restore current process signal mask. */
71 __libc_signal_restore_set (const sigset_t
*set
)
73 INTERNAL_SYSCALL_DECL (err
);
74 return INTERNAL_SYSCALL (rt_sigprocmask
, err
, 4, SIG_SETMASK
, set
, NULL
,
78 /* Used to communicate with signal handler. */
79 extern struct xid_command
*__xidcmd attribute_hidden
;