malloc: add glibc compat symbols
[uclibc-ng.git] / libc / signal / sigintr.c
blob83d34978c538f5b6a91cd5fcb24c970e1723e46a
1 /* Copyright (C) 1992, 1994, 1996, 2002 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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/>. */
18 #include <signal.h>
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
30 int siginterrupt (int sig, int interrupt)
32 #ifdef SA_RESTART
33 struct sigaction action;
35 /* Fails if sig is bad. */
36 if (sigaction (sig, NULL, &action) < 0)
37 return -1;
39 if (interrupt)
41 __sigaddset (&_sigintr, sig);
42 action.sa_flags &= ~SA_RESTART;
44 else
46 __sigdelset (&_sigintr, sig);
47 action.sa_flags |= SA_RESTART;
50 return sigaction (sig, &action, NULL);
51 #else
52 __set_errno (ENOSYS);
53 return -1;
54 #endif