summaryrefslogtreecommitdiff
path: root/signal
diff options
context:
space:
mode:
Diffstat (limited to 'signal')
-rw-r--r--signal/Makefile31
-rw-r--r--signal/Versions8
-rw-r--r--signal/allocrtsig.c2
-rw-r--r--signal/bits/types/__sigval_t.h41
-rw-r--r--signal/bits/types/sig_atomic_t.h10
-rw-r--r--signal/bits/types/sigset_t.h9
-rw-r--r--signal/bits/types/sigval_t.h18
-rw-r--r--signal/bits/types/struct_sigstack.h (renamed from signal/sigsetops.h)25
-rw-r--r--signal/kill.c3
-rw-r--r--signal/killpg.c2
-rw-r--r--signal/raise.c2
-rw-r--r--signal/sigaction.c4
-rw-r--r--signal/sigaddset.c13
-rw-r--r--signal/sigaltstack.c4
-rw-r--r--signal/sigandset.c10
-rw-r--r--signal/sigblock.c3
-rw-r--r--signal/sigdelset.c13
-rw-r--r--signal/sigempty.c2
-rw-r--r--signal/sigfillset.c12
-rw-r--r--signal/siggetmask.c2
-rw-r--r--signal/sighold.c12
-rw-r--r--signal/sigignore.c2
-rw-r--r--signal/sigintr.c2
-rw-r--r--signal/sigisempty.c9
-rw-r--r--signal/sigismem.c6
-rw-r--r--signal/signal.c2
-rw-r--r--signal/signal.h100
-rw-r--r--signal/sigorset.c10
-rw-r--r--signal/sigpause.c2
-rw-r--r--signal/sigpending.c2
-rw-r--r--signal/sigprocmask.c3
-rw-r--r--signal/sigqueue.c2
-rw-r--r--signal/sigrelse.c14
-rw-r--r--signal/sigreturn.c2
-rw-r--r--signal/sigset.c2
-rw-r--r--signal/sigsetmask.c2
-rw-r--r--signal/sigsetops.c58
-rw-r--r--signal/sigstack.c2
-rw-r--r--signal/sigsuspend.c2
-rw-r--r--signal/sigtimedwait.c2
-rw-r--r--signal/sigvec.c2
-rw-r--r--signal/sigwait.c2
-rw-r--r--signal/sigwaitinfo.c2
-rw-r--r--signal/sysv_signal.c2
-rw-r--r--signal/tst-raise.c2
-rw-r--r--signal/tst-sigaction.c56
-rw-r--r--signal/tst-sigset.c92
-rw-r--r--signal/tst-sigsimple.c2
-rw-r--r--signal/tst-sigwait-eintr.c85
49 files changed, 499 insertions, 196 deletions
diff --git a/signal/Makefile b/signal/Makefile
index 9d29ff49f3..aa63434f47 100644
--- a/signal/Makefile
+++ b/signal/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2016 Free Software Foundation, Inc.
+# Copyright (C) 1991-2018 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -22,9 +22,16 @@ subdir := signal
include ../Makeconfig
-headers := signal.h sys/signal.h bits/signum.h bits/sigcontext.h \
- bits/sigaction.h bits/sigset.h bits/siginfo.h bits/sigstack.h \
- bits/sigthread.h
+headers := signal.h sys/signal.h \
+ bits/signum.h bits/signum-generic.h \
+ bits/sigcontext.h bits/sigaction.h \
+ bits/sigevent-consts.h bits/siginfo-consts.h \
+ bits/sigstack.h bits/sigthread.h bits/ss_flags.h \
+ bits/types/__sigset_t.h bits/types/sig_atomic_t.h \
+ bits/types/sigevent_t.h bits/types/siginfo_t.h \
+ bits/types/sigset_t.h bits/types/sigval_t.h \
+ bits/types/stack_t.h bits/types/struct_sigstack.h \
+ bits/types/__sigval_t.h
routines := signal raise killpg \
sigaction sigprocmask kill \
@@ -38,13 +45,15 @@ routines := signal raise killpg \
allocrtsig sigtimedwait sigwaitinfo sigqueue \
sighold sigrelse sigignore sigset
-tests := tst-signal tst-sigset tst-sigsimple tst-raise tst-sigset2
-
+tests := tst-signal tst-sigset tst-sigsimple tst-raise tst-sigset2 \
+ tst-sigwait-eintr tst-sigaction \
include ../Rules
-CFLAGS-sigpause.c = -fexceptions
-CFLAGS-sigsuspend.c = -fexceptions -fasynchronous-unwind-tables
-CFLAGS-sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables
-CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
-CFLAGS-sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigpause.c += -fexceptions
+CFLAGS-sigsuspend.c += -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigtimedwait.c += -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigwait.c += -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigwaitinfo.c += -fexceptions -fasynchronous-unwind-tables
+
+CFLAGS-sigreturn.c += $(no-stack-protector)
diff --git a/signal/Versions b/signal/Versions
index 4d86930ec6..a915ef400f 100644
--- a/signal/Versions
+++ b/signal/Versions
@@ -1,13 +1,13 @@
libc {
GLIBC_2.0 {
# functions with special/multiple interfaces
- __sigaddset; __sigdelset; __sigismember; __sysv_signal;
+ __sigpause; __sysv_signal;
- # functions used in inline functions or macros
- __sigpause;
+ # functions formerly used in inline functions or macros
+ __sigaddset; __sigdelset; __sigismember;
# functions used in other libraries
- __sigaction;
+ __sigaction;
# b*
bsd_signal;
diff --git a/signal/allocrtsig.c b/signal/allocrtsig.c
index 463e5e3d05..fa642a52ea 100644
--- a/signal/allocrtsig.c
+++ b/signal/allocrtsig.c
@@ -1,5 +1,5 @@
/* Handle real-time signal allocation. Generic version.
- Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/signal/bits/types/__sigval_t.h b/signal/bits/types/__sigval_t.h
new file mode 100644
index 0000000000..395ce501e9
--- /dev/null
+++ b/signal/bits/types/__sigval_t.h
@@ -0,0 +1,41 @@
+/* Define __sigval_t.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef ____sigval_t_defined
+#define ____sigval_t_defined
+
+/* Type for data associated with a signal. */
+#ifdef __USE_POSIX199309
+union sigval
+{
+ int sival_int;
+ void *sival_ptr;
+};
+
+typedef union sigval __sigval_t;
+#else
+union __sigval
+{
+ int __sival_int;
+ void *__sival_ptr;
+};
+
+typedef union __sigval __sigval_t;
+#endif
+
+#endif
diff --git a/signal/bits/types/sig_atomic_t.h b/signal/bits/types/sig_atomic_t.h
new file mode 100644
index 0000000000..47eaa28311
--- /dev/null
+++ b/signal/bits/types/sig_atomic_t.h
@@ -0,0 +1,10 @@
+#ifndef __sig_atomic_t_defined
+#define __sig_atomic_t_defined 1
+
+#include <bits/types.h>
+
+/* An integral type that can be modified atomically, without the
+ possibility of a signal arriving in the middle of the operation. */
+typedef __sig_atomic_t sig_atomic_t;
+
+#endif
diff --git a/signal/bits/types/sigset_t.h b/signal/bits/types/sigset_t.h
new file mode 100644
index 0000000000..8b27e9112d
--- /dev/null
+++ b/signal/bits/types/sigset_t.h
@@ -0,0 +1,9 @@
+#ifndef __sigset_t_defined
+#define __sigset_t_defined 1
+
+#include <bits/types/__sigset_t.h>
+
+/* A set of signals to be blocked, unblocked, or waited for. */
+typedef __sigset_t sigset_t;
+
+#endif
diff --git a/signal/bits/types/sigval_t.h b/signal/bits/types/sigval_t.h
new file mode 100644
index 0000000000..a05d7f469f
--- /dev/null
+++ b/signal/bits/types/sigval_t.h
@@ -0,0 +1,18 @@
+#ifndef __sigval_t_defined
+#define __sigval_t_defined
+
+#include <bits/types/__sigval_t.h>
+
+/* To avoid sigval_t (not a standard type name) having C++ name
+ mangling depending on whether the selected standard includes union
+ sigval, it should not be defined at all when using a standard for
+ which the sigval name is not reserved; in that case, headers should
+ not include <bits/types/sigval_t.h> and should use only the
+ internal __sigval_t name. */
+#ifndef __USE_POSIX199309
+# error "sigval_t defined for standard not including union sigval"
+#endif
+
+typedef __sigval_t sigval_t;
+
+#endif
diff --git a/signal/sigsetops.h b/signal/bits/types/struct_sigstack.h
index b6e8dddccd..22da176654 100644
--- a/signal/sigsetops.h
+++ b/signal/bits/types/struct_sigstack.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Define struct sigstack.
+ Copyright (C) 1998-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -15,18 +16,14 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-/* Definitions relevant to functions that operate on `sigset_t's. */
+#ifndef __sigstack_defined
+#define __sigstack_defined 1
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
+/* Structure describing a signal stack (obsolete). */
+struct sigstack
+ {
+ void *ss_sp; /* Signal stack pointer. */
+ int ss_onstack; /* Nonzero if executing on this stack. */
+ };
-#define BITS (_NSIG - 1)
-#define ELT(signo) (((signo) - 1) / BITS)
-#define MASK(signo) (1 << (((signo) - 1) % BITS))
-
-#undef sigemptyset
-#undef sigfillset
-#undef sigaddset
-#undef sigdelset
-#undef sigismember
+#endif
diff --git a/signal/kill.c b/signal/kill.c
index b1dabb78aa..6368c2f10f 100644
--- a/signal/kill.c
+++ b/signal/kill.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -30,4 +30,5 @@ __kill (int pid, int sig)
}
stub_warning (kill)
+libc_hidden_def (__kill)
weak_alias (__kill, kill)
diff --git a/signal/killpg.c b/signal/killpg.c
index 1a70031a6d..86b99464fc 100644
--- a/signal/killpg.c
+++ b/signal/killpg.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/raise.c b/signal/raise.c
index 13194f2c74..2590adac4f 100644
--- a/signal/raise.c
+++ b/signal/raise.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigaction.c b/signal/sigaction.c
index b45e342276..c99001af42 100644
--- a/signal/sigaction.c
+++ b/signal/sigaction.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,7 +24,7 @@
int
__sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
{
- if (sig <= 0 || sig >= NSIG)
+ if (sig <= 0 || sig >= NSIG || __is_internal_signal (sig))
{
__set_errno (EINVAL);
return -1;
diff --git a/signal/sigaddset.c b/signal/sigaddset.c
index 2020cb48bb..cfb3373b13 100644
--- a/signal/sigaddset.c
+++ b/signal/sigaddset.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -15,18 +15,23 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include "sigsetops.h"
+#include <errno.h>
+#include <signal.h>
+#include <sigsetops.h>
+#include <internal-signals.h>
/* Add SIGNO to SET. */
int
sigaddset (sigset_t *set, int signo)
{
- if (set == NULL || signo <= 0 || signo >= NSIG)
+ if (set == NULL || signo <= 0 || signo >= NSIG
+ || __is_internal_signal (signo))
{
__set_errno (EINVAL);
return -1;
}
- return __sigaddset (set, signo);
+ __sigaddset (set, signo);
+ return 0;
}
libc_hidden_def (sigaddset)
diff --git a/signal/sigaltstack.c b/signal/sigaltstack.c
index 34e3545a65..39e0cb4b70 100644
--- a/signal/sigaltstack.c
+++ b/signal/sigaltstack.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
/* Run signals handlers on the stack specified by SS (if not NULL).
If OSS is not NULL, it is filled in with the old signal stack status. */
int
-sigaltstack (const struct sigaltstack *ss, struct sigaltstack *oss)
+sigaltstack (const stack_t *ss, stack_t *oss)
{
__set_errno (ENOSYS);
return -1;
diff --git a/signal/sigandset.c b/signal/sigandset.c
index e6a188fcd8..7bac42ce4d 100644
--- a/signal/sigandset.c
+++ b/signal/sigandset.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,18 +17,18 @@
#include <errno.h>
#include <signal.h>
-#define __need_NULL
-#include <stddef.h>
+#include <sigsetops.h>
/* Combine sets LEFT and RIGHT by logical AND and place result in DEST. */
int
sigandset (sigset_t *dest, const sigset_t *left, const sigset_t *right)
{
- if (dest == NULL || left == NULL || right == NULL)
+ if (!dest || !left || !right)
{
__set_errno (EINVAL);
return -1;
}
- return __sigandset (dest, left, right);
+ __sigandset (dest, left, right);
+ return 0;
}
diff --git a/signal/sigblock.c b/signal/sigblock.c
index f10b15b418..e04d6ee49d 100644
--- a/signal/sigblock.c
+++ b/signal/sigblock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -27,4 +27,5 @@ __sigblock (int mask)
}
stub_warning (sigblock)
+libc_hidden_def (__sigblock)
weak_alias (__sigblock, sigblock)
diff --git a/signal/sigdelset.c b/signal/sigdelset.c
index e60e166480..52f2ce6a36 100644
--- a/signal/sigdelset.c
+++ b/signal/sigdelset.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -15,18 +15,23 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include "sigsetops.h"
+#include <errno.h>
+#include <signal.h>
+#include <sigsetops.h>
+#include <internal-signals.h>
/* Add SIGNO to SET. */
int
sigdelset (sigset_t *set, int signo)
{
- if (set == NULL || signo <= 0 || signo >= NSIG)
+ if (set == NULL || signo <= 0 || signo >= NSIG
+ || __is_internal_signal (signo))
{
__set_errno (EINVAL);
return -1;
}
- return __sigdelset (set, signo);
+ __sigdelset (set, signo);
+ return 0;
}
libc_hidden_def (sigdelset)
diff --git a/signal/sigempty.c b/signal/sigempty.c
index 2c96de9bd9..446604d108 100644
--- a/signal/sigempty.c
+++ b/signal/sigempty.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigfillset.c b/signal/sigfillset.c
index 8ab9ec3a82..83dd583b7b 100644
--- a/signal/sigfillset.c
+++ b/signal/sigfillset.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,6 +18,7 @@
#include <errno.h>
#include <signal.h>
#include <string.h>
+#include <internal-signals.h>
/* Set all signals in SET. */
int
@@ -31,14 +32,7 @@ sigfillset (sigset_t *set)
memset (set, 0xff, sizeof (sigset_t));
- /* If the implementation uses a cancellation signal don't set the bit. */
-#ifdef SIGCANCEL
- __sigdelset (set, SIGCANCEL);
-#endif
- /* Likewise for the signal to implement setxid. */
-#ifdef SIGSETXID
- __sigdelset (set, SIGSETXID);
-#endif
+ __clear_internal_signals (set);
return 0;
}
diff --git a/signal/siggetmask.c b/signal/siggetmask.c
index 0deb33980f..200ed21c80 100644
--- a/signal/siggetmask.c
+++ b/signal/siggetmask.c
@@ -1,5 +1,5 @@
/* siggetmask -- useless alias for `sigblock (0)' for old Linux compatibility.
- Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sighold.c b/signal/sighold.c
index d1f9f6493e..32a95288a6 100644
--- a/signal/sighold.c
+++ b/signal/sighold.c
@@ -1,5 +1,5 @@
/* Add SIG to the calling process' signal mask.
- Copyright (C) 1998-2016 Free Software Foundation, Inc.
+ Copyright (C) 1998-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -26,14 +26,8 @@ sighold (int sig)
{
sigset_t set;
- /* Retrieve current signal set. */
- if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0)
- return -1;
-
- /* Add the specified signal. */
+ sigemptyset (&set);
if (sigaddset (&set, sig) < 0)
return -1;
-
- /* Set the new mask. */
- return __sigprocmask (SIG_SETMASK, &set, NULL);
+ return __sigprocmask (SIG_BLOCK, &set, NULL);
}
diff --git a/signal/sigignore.c b/signal/sigignore.c
index c695fe5d7f..8ec1dcc2af 100644
--- a/signal/sigignore.c
+++ b/signal/sigignore.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigintr.c b/signal/sigintr.c
index 002ea9f1c2..c73c858fb6 100644
--- a/signal/sigintr.c
+++ b/signal/sigintr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigisempty.c b/signal/sigisempty.c
index ec35debd43..949145ccc8 100644
--- a/signal/sigisempty.c
+++ b/signal/sigisempty.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,18 +17,17 @@
#include <errno.h>
#include <signal.h>
-#define __need_NULL
-#include <stddef.h>
+#include <sigsetops.h>
/* Test whether SET is empty. */
int
sigisemptyset (const sigset_t *set)
{
- if (set == NULL)
+ if (!set)
{
__set_errno (EINVAL);
return -1;
}
- return __sigisemptyset (set);
+ return __sigisemptyset (set);
}
diff --git a/signal/sigismem.c b/signal/sigismem.c
index ead8a05674..a919b33c37 100644
--- a/signal/sigismem.c
+++ b/signal/sigismem.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -15,7 +15,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include "sigsetops.h"
+#include <errno.h>
+#include <signal.h>
+#include <sigsetops.h>
/* Return 1 if SIGNO is in SET, 0 if not. */
int
diff --git a/signal/signal.c b/signal/signal.c
index 731d42c8b0..05d6a954b3 100644
--- a/signal/signal.c
+++ b/signal/signal.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/signal.h b/signal/signal.h
index 47e995a51c..87dc82a998 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,42 +20,21 @@
*/
#ifndef _SIGNAL_H
-
-#if !defined __need_sig_atomic_t && !defined __need_sigset_t
-# define _SIGNAL_H
-#endif
+#define _SIGNAL_H
#include <features.h>
__BEGIN_DECLS
-#include <bits/sigset.h> /* __sigset_t, __sig_atomic_t. */
+#include <bits/types.h>
+#include <bits/signum.h>
-/* An integral type that can be modified atomically, without the
- possibility of a signal arriving in the middle of the operation. */
-#if defined __need_sig_atomic_t || defined _SIGNAL_H
-# ifndef __sig_atomic_t_defined
-# define __sig_atomic_t_defined
-__BEGIN_NAMESPACE_STD
-typedef __sig_atomic_t sig_atomic_t;
-__END_NAMESPACE_STD
-# endif
-# undef __need_sig_atomic_t
-#endif
+#include <bits/types/sig_atomic_t.h>
-#if defined __need_sigset_t || (defined _SIGNAL_H && defined __USE_POSIX)
-# ifndef __sigset_t_defined
-# define __sigset_t_defined
-typedef __sigset_t sigset_t;
-# endif
-# undef __need_sigset_t
+#if defined __USE_POSIX
+#include <bits/types/sigset_t.h>
#endif
-#ifdef _SIGNAL_H
-
-#include <bits/types.h>
-#include <bits/signum.h>
-
#if defined __USE_XOPEN || defined __USE_XOPEN2K
# ifndef __pid_t_defined
typedef __pid_t pid_t;
@@ -71,13 +50,21 @@ typedef __uid_t uid_t;
#ifdef __USE_POSIX199309
/* We need `struct timespec' later on. */
-# define __need_timespec
-# include <time.h>
+# include <bits/types/struct_timespec.h>
#endif
#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
-/* Get the `siginfo_t' type plus the needed symbols. */
-# include <bits/siginfo.h>
+# include <bits/types/siginfo_t.h>
+# include <bits/siginfo-consts.h>
+#endif
+
+#ifdef __USE_MISC
+# include <bits/types/sigval_t.h>
+#endif
+
+#ifdef __USE_POSIX199309
+# include <bits/types/sigevent_t.h>
+# include <bits/sigevent-consts.h>
#endif
@@ -97,7 +84,6 @@ extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler)
/* Set the handler for the signal SIG to HANDLER, returning the old
handler, or SIG_ERR on error.
By default `signal' has the BSD semantic. */
-__BEGIN_NAMESPACE_STD
#ifdef __USE_MISC
extern __sighandler_t signal (int __sig, __sighandler_t __handler)
__THROW;
@@ -111,9 +97,8 @@ extern __sighandler_t __REDIRECT_NTH (signal,
# define signal __sysv_signal
# endif
#endif
-__END_NAMESPACE_STD
-#ifdef __USE_XOPEN
+#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8
/* The X/Open definition of `signal' conflicts with the BSD version.
So they defined another function `bsd_signal'. */
extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)
@@ -134,10 +119,8 @@ extern int kill (__pid_t __pid, int __sig) __THROW;
extern int killpg (__pid_t __pgrp, int __sig) __THROW;
#endif /* Use misc || X/Open Unix. */
-__BEGIN_NAMESPACE_STD
/* Raise signal SIG, i.e., send SIG to yourself. */
extern int raise (int __sig) __THROW;
-__END_NAMESPACE_STD
#ifdef __USE_MISC
/* SVID names for the same things. */
@@ -163,7 +146,7 @@ extern void psiginfo (const siginfo_t *__pinfo, const char *__s);
This function is a cancellation point and therefore not marked with
__THROW. */
-#ifdef __USE_XOPEN
+#ifdef __USE_XOPEN_EXTENDED
# ifdef __GNUC__
extern int sigpause (int __sig) __asm__ ("__xpg_sigpause");
# else
@@ -181,7 +164,7 @@ extern int __sigpause (int __sig_or_mask, int __is_sig);
simply do not work in many situations. Use `sigprocmask' instead. */
/* Compute mask for signal SIG. */
-# define sigmask(sig) __sigmask(sig)
+# define sigmask(sig) ((int)(1u << ((sig) - 1)))
/* Block signals in MASK, returning the old mask. */
extern int sigblock (int __mask) __THROW __attribute_deprecated__;
@@ -261,12 +244,14 @@ extern int sigaction (int __sig, const struct sigaction *__restrict __act,
extern int sigpending (sigset_t *__set) __THROW __nonnull ((1));
+# ifdef __USE_POSIX199506
/* Select any of pending signals from SET or wait for any to arrive.
This function is a cancellation point and therefore not marked with
__THROW. */
extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig)
__nonnull ((1, 2));
+# endif /* Use POSIX 1995. */
# ifdef __USE_POSIX199309
/* Select any of pending signals from SET and place information in INFO.
@@ -315,29 +300,41 @@ extern int sigreturn (struct sigcontext *__scp) __THROW;
# define __need_size_t
# include <stddef.h>
+# include <bits/types/stack_t.h>
+# if defined __USE_XOPEN || defined __USE_XOPEN2K8
+/* This will define `ucontext_t' and `mcontext_t'. */
+# include <sys/ucontext.h>
+# endif
+#endif /* Use POSIX.1-2008 or X/Open Unix. */
+
+#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC
/* If INTERRUPT is nonzero, make signal SIG interrupt system calls
(causing them to fail with EINTR); if INTERRUPT is zero, make system
calls be restarted after signal SIG. */
extern int siginterrupt (int __sig, int __interrupt) __THROW;
# include <bits/sigstack.h>
-# if defined __USE_XOPEN || defined __USE_XOPEN2K8
-/* This will define `ucontext_t' and `mcontext_t'. */
-# include <sys/ucontext.h>
-# endif
+# include <bits/ss_flags.h>
+
+/* Alternate signal handler stack interface.
+ This interface should always be preferred over `sigstack'. */
+extern int sigaltstack (const stack_t *__restrict __ss,
+ stack_t *__restrict __oss) __THROW;
+#endif /* __USE_XOPEN_EXTENDED || __USE_MISC */
+#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
+ || defined __USE_MISC)
+# include <bits/types/struct_sigstack.h>
+#endif
+
+#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \
+ || defined __USE_MISC)
/* Run signals handlers on the stack specified by SS (if not NULL).
If OSS is not NULL, it is filled in with the old signal stack status.
This interface is obsolete and on many platform not implemented. */
extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
__THROW __attribute_deprecated__;
-
-/* Alternate signal handler stack interface.
- This interface should always be preferred over `sigstack'. */
-extern int sigaltstack (const struct sigaltstack *__restrict __ss,
- struct sigaltstack *__restrict __oss) __THROW;
-
-#endif /* Use POSIX.1-2008 or X/Open Unix. */
+#endif
#ifdef __USE_XOPEN_EXTENDED
/* Simplified interface for signal management. */
@@ -370,7 +367,8 @@ extern int __libc_current_sigrtmin (void) __THROW;
/* Return number of available real-time signal with lowest priority. */
extern int __libc_current_sigrtmax (void) __THROW;
-#endif /* signal.h */
+#define SIGRTMIN (__libc_current_sigrtmin ())
+#define SIGRTMAX (__libc_current_sigrtmax ())
__END_DECLS
diff --git a/signal/sigorset.c b/signal/sigorset.c
index 13573d72a5..e6c66f12f3 100644
--- a/signal/sigorset.c
+++ b/signal/sigorset.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,18 +17,18 @@
#include <errno.h>
#include <signal.h>
-#define __need_NULL
-#include <stddef.h>
+#include <sigsetops.h>
/* Combine sets LEFT and RIGHT by logical OR and place result in DEST. */
int
sigorset (sigset_t *dest, const sigset_t *left, const sigset_t *right)
{
- if (dest == NULL || left == NULL || right == NULL)
+ if (!dest || !left || !right)
{
__set_errno (EINVAL);
return -1;
}
- return __sigorset (dest, left, right);
+ __sigorset (dest, left, right);
+ return 0;
}
diff --git a/signal/sigpause.c b/signal/sigpause.c
index c572ef095f..43f570e55a 100644
--- a/signal/sigpause.c
+++ b/signal/sigpause.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigpending.c b/signal/sigpending.c
index 12e0faeba9..f474e8e17e 100644
--- a/signal/sigpending.c
+++ b/signal/sigpending.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigprocmask.c b/signal/sigprocmask.c
index 2ec23864b8..55371d0b15 100644
--- a/signal/sigprocmask.c
+++ b/signal/sigprocmask.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -44,4 +44,5 @@ __sigprocmask (int how, const sigset_t *set, sigset_t *oset)
and we don't want warnings for every use of abort on
a system without safe signals. */
+libc_hidden_def (__sigprocmask)
weak_alias (__sigprocmask, sigprocmask)
diff --git a/signal/sigqueue.c b/signal/sigqueue.c
index 9fe02a714c..8b2bfd6b4f 100644
--- a/signal/sigqueue.c
+++ b/signal/sigqueue.c
@@ -1,5 +1,5 @@
/* Implementation of sigqueue function from POSIX.1b.
- Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigrelse.c b/signal/sigrelse.c
index 5dcba53ec1..c08bbc8d56 100644
--- a/signal/sigrelse.c
+++ b/signal/sigrelse.c
@@ -1,5 +1,5 @@
/* Remove SIG from the calling process' signal mask.
- Copyright (C) 1998-2016 Free Software Foundation, Inc.
+ Copyright (C) 1998-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -26,14 +26,8 @@ sigrelse (int sig)
{
sigset_t set;
- /* Retrieve current signal set. */
- if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0)
+ sigemptyset (&set);
+ if (sigaddset (&set, sig) < 0)
return -1;
-
- /* Remove the specified signal. */
- if (sigdelset (&set, sig) < 0)
- return -1;
-
- /* Set the new mask. */
- return __sigprocmask (SIG_SETMASK, &set, NULL);
+ return __sigprocmask (SIG_UNBLOCK, &set, NULL);
}
diff --git a/signal/sigreturn.c b/signal/sigreturn.c
index a0797c62ea..92aaae6dd3 100644
--- a/signal/sigreturn.c
+++ b/signal/sigreturn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigset.c b/signal/sigset.c
index f475772e76..bd6d8b851b 100644
--- a/signal/sigset.c
+++ b/signal/sigset.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigsetmask.c b/signal/sigsetmask.c
index 504359cc2d..d223034df0 100644
--- a/signal/sigsetmask.c
+++ b/signal/sigsetmask.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigsetops.c b/signal/sigsetops.c
index 0317662a14..312b5e5b32 100644
--- a/signal/sigsetops.c
+++ b/signal/sigsetops.c
@@ -1,11 +1,53 @@
-/* Define the real-function versions of all inline functions
- defined in signal.h (or bits/sigset.h). */
+/* Compatibility symbols for old versions of signal.h.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
-#include <features.h>
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-#define _EXTERN_INLINE
-#ifndef __USE_EXTERN_INLINES
-# define __USE_EXTERN_INLINES 1
-#endif
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+#include <sigsetops.h>
+#include <shlib-compat.h>
+
+/* These were formerly defined by <signal.h> as inline functions,
+ so they require out-of-line compatibility definitions. */
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_26)
-#include "signal.h"
+int
+attribute_compat_text_section
+(__sigismember) (const __sigset_t *set, int sig)
+{
+ return __sigismember (set, sig);
+}
+compat_symbol (libc, __sigismember, __sigismember, GLIBC_2_0);
+
+int
+attribute_compat_text_section
+(__sigaddset) (__sigset_t *set, int sig)
+{
+ __sigaddset (set, sig);
+ return 0;
+}
+compat_symbol (libc, __sigaddset, __sigaddset, GLIBC_2_0);
+
+int
+attribute_compat_text_section
+(__sigdelset) (__sigset_t *set, int sig)
+{
+ __sigdelset (set, sig);
+ return 0;
+}
+compat_symbol (libc, __sigdelset, __sigdelset, GLIBC_2_0);
+
+#endif
diff --git a/signal/sigstack.c b/signal/sigstack.c
index b3b7dcec46..1b28180042 100644
--- a/signal/sigstack.c
+++ b/signal/sigstack.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigsuspend.c b/signal/sigsuspend.c
index 8e2cda58dd..55577578a4 100644
--- a/signal/sigsuspend.c
+++ b/signal/sigsuspend.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigtimedwait.c b/signal/sigtimedwait.c
index 90e4244297..308b9b95d7 100644
--- a/signal/sigtimedwait.c
+++ b/signal/sigtimedwait.c
@@ -1,5 +1,5 @@
/* Implementation of sigtimedwait function from POSIX.1b.
- Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigvec.c b/signal/sigvec.c
index 1c73fb6318..48ca55428e 100644
--- a/signal/sigvec.c
+++ b/signal/sigvec.c
@@ -1,5 +1,5 @@
/* ABI compatibility for obsolete sigvec function from 4.2BSD.
- Copyright (C) 1991-2016 Free Software Foundation, Inc.
+ Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigwait.c b/signal/sigwait.c
index d87676bcd7..4273281d9c 100644
--- a/signal/sigwait.c
+++ b/signal/sigwait.c
@@ -1,5 +1,5 @@
/* sigwait - implementation of sigwait function from POSIX.1c.
- Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sigwaitinfo.c b/signal/sigwaitinfo.c
index 6c32f3e424..44ac0223d2 100644
--- a/signal/sigwaitinfo.c
+++ b/signal/sigwaitinfo.c
@@ -1,5 +1,5 @@
/* Implementation of sigwaitinfo function from POSIX.1b.
- Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/sysv_signal.c b/signal/sysv_signal.c
index 3010c3ec7f..e4416cb25e 100644
--- a/signal/sysv_signal.c
+++ b/signal/sysv_signal.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/signal/tst-raise.c b/signal/tst-raise.c
index 889cc6288a..0c51ad2869 100644
--- a/signal/tst-raise.c
+++ b/signal/tst-raise.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
diff --git a/signal/tst-sigaction.c b/signal/tst-sigaction.c
new file mode 100644
index 0000000000..c908e8f6f6
--- /dev/null
+++ b/signal/tst-sigaction.c
@@ -0,0 +1,56 @@
+/* Test sigaction regression for BZ #23069.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+static void
+my_sig_handler (int signum)
+{
+}
+
+static int
+do_test (void)
+{
+ /* Define a simple signal handler */
+ struct sigaction act;
+ act.sa_handler = my_sig_handler;
+ act.sa_flags = 0;
+ sigemptyset (&act.sa_mask);
+
+ /* Set it as SIGUSR1 signal handler */
+ TEST_VERIFY_EXIT (sigaction (SIGUSR1, &act, NULL) == 0);
+
+ /* Get SIGUSR1 signal handler */
+ TEST_VERIFY_EXIT (sigaction (SIGUSR1, NULL, &act) == 0);
+
+ /* Check it is consistent with the defined one */
+ TEST_VERIFY (act.sa_handler == my_sig_handler);
+ TEST_VERIFY (!(act.sa_flags & SA_RESETHAND));
+
+ for (int i = 1; i < _NSIG; i++)
+ {
+ TEST_VERIFY (!sigismember (&act.sa_mask, i));
+ }
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/signal/tst-sigset.c b/signal/tst-sigset.c
index d47adcc0d4..a2b764de5a 100644
--- a/signal/tst-sigset.c
+++ b/signal/tst-sigset.c
@@ -1,43 +1,85 @@
/* Test sig*set functions. */
#include <signal.h>
-#include <stdio.h>
-#define TEST_FUNCTION do_test ()
+#include <support/check.h>
+
static int
do_test (void)
{
- int result = 0;
- int sig = -1;
+ sigset_t set;
+ TEST_VERIFY (sigemptyset (&set) == 0);
-#define TRY(call) \
- if (call) \
- { \
- printf ("%s (sig = %d): %m\n", #call, sig); \
- result = 1; \
- } \
- else
+#define VERIFY(set, sig) \
+ TEST_VERIFY (sigismember (&set, sig) == 0); \
+ TEST_VERIFY (sigaddset (&set, sig) == 0); \
+ TEST_VERIFY (sigismember (&set, sig) != 0); \
+ TEST_VERIFY (sigdelset (&set, sig) == 0); \
+ TEST_VERIFY (sigismember (&set, sig) == 0)
+ /* ISO C99 signals. */
+ VERIFY (set, SIGINT);
+ VERIFY (set, SIGILL);
+ VERIFY (set, SIGABRT);
+ VERIFY (set, SIGFPE);
+ VERIFY (set, SIGSEGV);
+ VERIFY (set, SIGTERM);
- sigset_t set;
- TRY (sigemptyset (&set) != 0);
+ /* Historical signals specified by POSIX. */
+ VERIFY (set, SIGHUP);
+ VERIFY (set, SIGQUIT);
+ VERIFY (set, SIGTRAP);
+ VERIFY (set, SIGKILL);
+ VERIFY (set, SIGBUS);
+ VERIFY (set, SIGSYS);
+ VERIFY (set, SIGPIPE);
+ VERIFY (set, SIGALRM);
+
+ /* New(er) POSIX signals (1003.1-2008, 1003.1-2013). */
+ VERIFY (set, SIGURG);
+ VERIFY (set, SIGSTOP);
+ VERIFY (set, SIGTSTP);
+ VERIFY (set, SIGCONT);
+ VERIFY (set, SIGCHLD);
+ VERIFY (set, SIGTTIN);
+ VERIFY (set, SIGTTOU);
+ VERIFY (set, SIGPOLL);
+ VERIFY (set, SIGXCPU);
+ VERIFY (set, SIGXFSZ);
+ VERIFY (set, SIGVTALRM);
+ VERIFY (set, SIGPROF);
+ VERIFY (set, SIGUSR1);
+ VERIFY (set, SIGUSR2);
+
+ /* Nonstandard signals found in all modern POSIX systems
+ (including both BSD and Linux). */
+ VERIFY (set, SIGWINCH);
-#ifdef SIGRTMAX
- int max_sig = SIGRTMAX;
-#else
- int max_sig = NSIG - 1;
+ /* Arch-specific signals. */
+#ifdef SIGEMT
+ VERIFY (set, SIGEMT);
+#endif
+#ifdef SIGLOST
+ VERIFY (set, SIGLOST);
+#endif
+#ifdef SIGINFO
+ VERIFY (set, SIGINFO);
+#endif
+#ifdef SIGSTKFLT
+ VERIFY (set, SIGSTKFLT);
+#endif
+#ifdef SIGPWR
+ VERIFY (set, SIGPWR);
#endif
- for (sig = 1; sig <= max_sig; ++sig)
+ /* Read-time signals (POSIX.1b real-time extensions). If they are
+ supported SIGRTMAX value is greater than SIGRTMIN. */
+ for (int rtsig = SIGRTMIN; rtsig <= SIGRTMAX; rtsig++)
{
- TRY (sigismember (&set, sig) != 0);
- TRY (sigaddset (&set, sig) != 0);
- TRY (sigismember (&set, sig) == 0);
- TRY (sigdelset (&set, sig) != 0);
- TRY (sigismember (&set, sig) != 0);
+ VERIFY (set, rtsig);
}
- return result;
+ return 0;
}
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/signal/tst-sigsimple.c b/signal/tst-sigsimple.c
index ea65a5d46a..20c3ea3782 100644
--- a/signal/tst-sigsimple.c
+++ b/signal/tst-sigsimple.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
diff --git a/signal/tst-sigwait-eintr.c b/signal/tst-sigwait-eintr.c
new file mode 100644
index 0000000000..d748a5432f
--- /dev/null
+++ b/signal/tst-sigwait-eintr.c
@@ -0,0 +1,85 @@
+/* Check that sigwait does not fail with EINTR (bug 22478).
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <time.h>
+#include <unistd.h>
+
+/* Handler for SIGUSR1. */
+static void
+sigusr1_handler (int signo)
+{
+ TEST_VERIFY (signo == SIGUSR1);
+}
+
+/* Spawn a subprocess to send two signals: First SIGUSR1, then
+ SIGUSR2. Return the PID of the process. */
+static pid_t
+signal_sender (void)
+{
+ pid_t pid = xfork ();
+ if (pid == 0)
+ {
+ static const struct timespec delay = { 1, };
+ if (nanosleep (&delay, NULL) != 0)
+ FAIL_EXIT1 ("nanosleep: %m");
+ if (kill (getppid (), SIGUSR1) != 0)
+ FAIL_EXIT1 ("kill (SIGUSR1): %m");
+ if (nanosleep (&delay, NULL) != 0)
+ FAIL_EXIT1 ("nanosleep: %m");
+ if (kill (getppid (), SIGUSR2) != 0)
+ FAIL_EXIT1 ("kill (SIGUSR2): %m");
+ _exit (0);
+ }
+ return pid;
+}
+
+static int
+do_test (void)
+{
+ if (signal (SIGUSR1, sigusr1_handler) == SIG_ERR)
+ FAIL_EXIT1 ("signal (SIGUSR1): %m\n");
+
+ sigset_t sigs;
+ sigemptyset (&sigs);
+ sigaddset (&sigs, SIGUSR2);
+ if (sigprocmask (SIG_BLOCK, &sigs, NULL) != 0)
+ FAIL_EXIT1 ("sigprocmask (SIGBLOCK, SIGUSR2): %m");
+ pid_t pid = signal_sender ();
+ int signo = 0;
+ int ret = sigwait (&sigs, &signo);
+ if (ret != 0)
+ {
+ support_record_failure ();
+ errno = ret;
+ printf ("error: sigwait failed: %m (%d)\n", ret);
+ }
+ TEST_VERIFY (signo == SIGUSR2);
+
+ int status;
+ xwaitpid (pid, &status, 0);
+ TEST_VERIFY (status == 0);
+
+ return 0;
+}
+
+#include <support/test-driver.c>