aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/posix/sigpause.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/posix/sigpause.c')
-rw-r--r--sysdeps/posix/sigpause.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/sysdeps/posix/sigpause.c b/sysdeps/posix/sigpause.c
index 020a46b..b3eec8f 100644
--- a/sysdeps/posix/sigpause.c
+++ b/sysdeps/posix/sigpause.c
@@ -22,25 +22,35 @@
/* Set the mask of blocked signals to MASK,
wait for a signal to arrive, and then restore the mask. */
int
-__sigpause (mask)
- int mask;
+__sigpause (sig_or_mask, is_sig)
+ int sig_or_mask;
+ int is_sig;
{
sigset_t set;
int sig;
- if (__sigemptyset (&set) < 0)
- return -1;
-
- if (sizeof (mask) == sizeof (set))
- *(int *) &set = mask;
- else if (sizeof (unsigned long int) == sizeof (set))
- *(unsigned long int *) &set = (unsigned int) mask;
+ if (is_sig != 0)
+ {
+ /* The modern X/Open implementation is requested. */
+ if (sigprocmask (0, NULL, &set) < 0
+ /* Yes, we call `sigaddset' and not `__sigaddset'. */
+ || sigaddset (&set, sig_or_mask) < 0)
+ return -1;
+ }
else
- for (sig = 1; sig < NSIG; ++sig)
- if ((mask & sigmask (sig)) && __sigaddset (&set, sig) < 0)
+ {
+ if (__sigemptyset (&set) < 0)
return -1;
+ if (sizeof (sig_or_mask) == sizeof (set))
+ *(int *) &set = sig_or_mask;
+ else if (sizeof (unsigned long int) == sizeof (set))
+ *(unsigned long int *) &set = (unsigned int) sig_or_mask;
+ else
+ for (sig = 1; sig < NSIG; ++sig)
+ if ((sig_or_mask & sigmask (sig)) && __sigaddset (&set, sig) < 0)
+ return -1;
+ }
+
return sigsuspend (&set);
}
-
-weak_alias (__sigpause, sigpause)