1 /* Copyright (C) 1997-2015 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
24 #include <sys/syscall.h>
26 #define SA_RESTORER 0x04000000
28 /* The difference here is that the sigaction structure used in the
29 kernel is not the same as we use in the libc. Therefore we must
31 #include <kernel_sigaction.h>
34 __libc_sigaction (int sig
, const struct sigaction
*act
, struct sigaction
*oact
)
37 struct kernel_sigaction kact
;
38 struct kernel_sigaction koact
;
42 kact
.k_sa_handler
= act
->sa_handler
;
43 memcpy (&kact
.sa_mask
, &act
->sa_mask
, sizeof (sigset_t
));
44 kact
.sa_flags
= act
->sa_flags
;
45 #ifdef HAVE_SA_RESTORER
46 if (kact
.sa_flags
& SA_RESTORER
)
47 kact
.sa_restorer
= act
->sa_restorer
;
51 result
= INLINE_SYSCALL (rt_sigaction
, 4, sig
,
53 oact
? &koact
: NULL
, _NSIG
/ 8);
54 if (result
>= 0 || errno
!= ENOSYS
)
56 if (oact
&& result
>= 0)
58 oact
->sa_handler
= koact
.k_sa_handler
;
59 memcpy (&oact
->sa_mask
, &koact
.sa_mask
, sizeof (sigset_t
));
60 oact
->sa_flags
= koact
.sa_flags
;
61 #ifdef HAVE_SA_RESTORER
62 oact
->sa_restorer
= koact
.sa_restorer
;
68 libc_hidden_def (__libc_sigaction
)
70 #include <nptl/sigaction.c>