Update.
[glibc.git] / sysdeps / posix / sigpause.c
blob71818740edfa265ef87afc8d13abfafc1810f752
1 /* Copyright (C) 1991,92,94-98,2000,02 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, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #include <errno.h>
20 #include <signal.h>
21 #include <stddef.h> /* For NULL. */
23 #include <sigset-cvt-mask.h>
25 /* Set the mask of blocked signals to MASK,
26 wait for a signal to arrive, and then restore the mask. */
27 int
28 __sigpause (int sig_or_mask, int is_sig)
30 sigset_t set;
32 if (is_sig != 0)
34 /* The modern X/Open implementation is requested. */
35 if (__sigprocmask (0, NULL, &set) < 0
36 /* Yes, we call `sigdelset' and not `__sigdelset'. */
37 || __sigdelset (&set, sig_or_mask) < 0)
38 return -1;
40 else if (sigset_set_old_mask (&set, sig_or_mask) < 0)
41 return -1;
43 return __sigsuspend (&set);
45 libc_hidden_def (__sigpause)
47 /* We have to provide a default version of this function since the
48 standards demand it. The version which is a bit more reasonable is
49 the BSD version. So make this the default. */
50 int
51 __default_sigpause (int mask)
53 return __sigpause (mask, 0);
55 #undef sigpause
56 weak_alias (__default_sigpause, sigpause)
59 /* We have to provide a default version of this function since the
60 standards demand it. The version which is a bit more reasonable is
61 the BSD version. So make this the default. */
62 int
63 __xpg_sigpause (int sig)
65 return __sigpause (sig, 1);