]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/signal/sigintr.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / signal / sigintr.c
1 /* Copyright (C) 1992, 1994, 1996, 2002 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
17
18 #include <signal.h>
19
20 /* If INTERRUPT is nonzero, make signal SIG interrupt system calls
21    (causing them to fail with EINTR); if INTERRUPT is zero, make system
22    calls be restarted after signal SIG.  */
23 #ifdef SA_RESTART
24 # define __need_NULL
25 # include <stddef.h>
26 #else
27 # include <errno.h>
28 #endif
29
30 int siginterrupt (int sig, int interrupt)
31 {
32 #ifdef  SA_RESTART
33   struct sigaction action;
34
35   /* Fails if sig is bad.  */
36   if (sigaction (sig, NULL, &action) < 0)
37     return -1;
38
39   if (interrupt)
40     {
41       __sigaddset (&_sigintr, sig);
42       action.sa_flags &= ~SA_RESTART;
43     }
44   else
45     {
46       __sigdelset (&_sigintr, sig);
47       action.sa_flags |= SA_RESTART;
48     }
49
50   return sigaction (sig, &action, NULL);
51 #else
52   __set_errno (ENOSYS);
53   return -1;
54 #endif
55 }