]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Don’t include signal.h from sys/wait.h or sys/param.h.
authorZack Weinberg <zackw@panix.com>
Mon, 10 Jun 2019 15:34:41 +0000 (11:34 -0400)
committerZack Weinberg <zackw@panix.com>
Wed, 8 Jan 2020 18:45:44 +0000 (13:45 -0500)
Besides the snarl of debugger/ucontext interfaces, these are the only
public headers that include signal.h.

sys/wait.h includes signal.h only for the definition of siginfo_t.
We already have a single-type header for that, so use it.  siginfo_t
contains a field whose type is uid_t, but sys/wait.h is not specified
to define uid_t, so, as is already done for pid_t, the conformance
test is modified to expect that field to have type __uid_t instead.

It is not clear what subset of the definitions from signal.h are
actually expected by historical users of sys/param.h; I’ve chosen to
take the comment at face value and cut it down to bits/signum.h, which
supplies _NSIG and all of the SIG* constants.  This requires adjusting
every copy of bits/signum.h to permit inclusion by sys/param.h as well
as signal.h.

While I was at it I moved the comment about sys/param.h being obsolete
from sysdeps/mach/hurd/bits/param.h, where it’s not likely to be seen,
to the top-level sys/param.h, and edited it to give more useful advice.

This patch partially fixes Hurd-specific bug 23088; sys/wait.h is now
conformant.

* posix/sys/wait.h: Include bits/types/siginfo_t.h, not signal.h.
* conform/data/sys/wait.h-data: Do not expect a definition of uid_t.

* malloc/tst-mallocfork.c, nptl/tst-fork4.c, nptl/tst-getpid3.c
* nptl/tst-mutex9.c, nptl/tst-rwlock12.c
* resolv/tst-resolv-res_init-skeleton.c
* sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c:
        Include signal.h.

* nptl/tst-cancel4.c, rt/tst-mqueue1.c
* support/tst-support_capture_subprocess.c
* sysdeps/unix/sysv/linux/tst-align-clone.c:
Include signal.h.  Sort includes.

* misc/sys/param.h: Include bits/signum.h, not signal.h.
Add comment explaining that this header is obsolete, based on
a similar comment in Hurd bits/param.h.

* bits/param.h: Add multiple inclusion guard and defensive #error.
* sysdeps/mach/hurd/bits/param.h: Add multiple inclusion guard.
Remove comment explaining that this header is obsolete (see above).
* sysdeps/mach/i386/bits/mach/param.h: Add multiple inclusion guard.
* sysdeps/unix/sysv/linux/bits/param.h: Add multiple inclusion guard.

* bits/signum-generic.h, bits/signum.h
* sysdeps/unix/bsd/bits/signum.h
* sysdeps/unix/sysv/linux/alpha/bits/signum.h
* sysdeps/unix/sysv/linux/bits/signum.h
* sysdeps/unix/sysv/linux/hppa/bits/signum.h
* sysdeps/unix/sysv/linux/mips/bits/signum.h:
Allow inclusion by sys/param.h as well as signal.h.

* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
Update.

        * sysdeps/mach/hurd/i386/Makefile: Remove XFAILs for sys/wait.h.

28 files changed:
bits/param.h
bits/signum-generic.h
bits/signum.h
conform/data/sys/wait.h-data
malloc/tst-mallocfork.c
misc/sys/param.h
nptl/tst-cancel4.c
nptl/tst-fork4.c
nptl/tst-getpid3.c
nptl/tst-mutex9.c
nptl/tst-rwlock12.c
posix/sys/wait.h
resolv/tst-resolv-res_init-skeleton.c
rt/tst-mqueue1.c
scripts/check-obsolete-constructs.py
support/tst-support_capture_subprocess.c
sysdeps/mach/hurd/bits/param.h
sysdeps/mach/hurd/i386/Makefile
sysdeps/mach/i386/bits/mach/param.h
sysdeps/unix/bsd/bits/signum.h
sysdeps/unix/sysv/linux/alpha/bits/signum.h
sysdeps/unix/sysv/linux/bits/param.h
sysdeps/unix/sysv/linux/bits/signum.h
sysdeps/unix/sysv/linux/hppa/bits/signum.h
sysdeps/unix/sysv/linux/mips/bits/signum.h
sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c
sysdeps/unix/sysv/linux/sparc/bits/signum.h
sysdeps/unix/sysv/linux/tst-align-clone.c

index df5634ee3460260905a63f15717021f88248d850..9528af9747c3a3866185fa5a0a6c3d780f410c10 100644 (file)
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
 #ifndef _SYS_PARAM_H
 # error "Never use <bits/param.h> directly; include <sys/param.h> instead."
 #endif
@@ -31,3 +34,7 @@
 
         EXEC_PAGESIZE
 */
+
+#error "Generic bits/param.h should not have been used."
+
+#endif
index 504e5fb8c8d3e315f4ed5a3f504aa9aa1e00accc..6c6281a5b687718aaf147b426873bcc45b53c769 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef        _BITS_SIGNUM_GENERIC_H
 #define _BITS_SIGNUM_GENERIC_H 1
 
-#ifndef _SIGNAL_H
+#if !defined _SIGNAL_H && !defined _SYS_PARAM_H
 #error "Never include <bits/signum-generic.h> directly; use <signal.h> instead."
 #endif
 
index 183e3c05455ca4aef900c5b69f0409d5bd612b5b..5361e00f41af364f40512e5b3a5976b87e864399 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef _BITS_SIGNUM_H
 #define _BITS_SIGNUM_H 1
 
-#ifndef _SIGNAL_H
+#if !defined _SIGNAL_H && !defined _SYS_PARAM_H
 #error "Never include <bits/signum.h> directly; use <signal.h> instead."
 #endif
 
index c0761424daa15738ccc607d6fe381bd3a46478d0..aa3a87ea15d5e829852a826ffcdf07dda13a454d 100644 (file)
@@ -2,6 +2,7 @@
 #ifdef  POSIX
 # define pid_t __pid_t
 #endif
+#define uid_t __uid_t
 
 constant WNOHANG
 constant WUNTRACED
index 00851a16c3f15a5f30be1bda42677dad3d3e3f4b..d1d973c28b443f2f952214213c86a3523531b9c3 100644 (file)
@@ -2,6 +2,7 @@
    https://sourceware.org/bugzilla/show_bug.cgi?id=838.  */
 #include <assert.h>
 #include <errno.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
index eca50cf9bf48a67d8cd539f8402497a365810789..c50c4ced018625436721a88471291bfa73e3d70a 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+/* This header is provided only for compatibility with historic Unix
+   systems.  New programs should use some combination of <endian.h>,
+   <limits.h>, <signal.h>, <stddef.h>, <stdint.h>, and <sys/types.h>
+   instead, and the names defined in those headers.  The utility
+   macros at the end of this header should not be used at all.  */
+
 #ifndef _SYS_PARAM_H
 #define _SYS_PARAM_H    1
 
@@ -24,7 +30,7 @@
 #include <sys/types.h>
 #include <limits.h>
 #include <endian.h>                     /* Define BYTE_ORDER et al.  */
-#include <signal.h>                     /* Define NSIG.  */
+#include <bits/signum.h>                /* Define NSIG.  */
 #include <bits/NULL.h>
 
 /* This file defines some things in system-specific ways.  */
index 5ede8a0caa85ae259d1ecfbd69f5dae500742ef6..4931bf3a39754c566a31acbec388ab1937120afb 100644 (file)
 /* NOTE: this tests functionality beyond POSIX.  POSIX does not allow
    exit to be called more than once.  */
 
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pthread.h>
+#include <signal.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/select.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/ipc.h>
-#include <sys/msg.h>
-#include <unistd.h>
-#include <errno.h>
-#include <limits.h>
-#include <pthread.h>
-#include <fcntl.h>
 #include <termios.h>
+#include <unistd.h>
+#include <sys/ipc.h>
 #include <sys/mman.h>
+#include <sys/msg.h>
 #include <sys/poll.h>
-#include <sys/wait.h>
+#include <sys/select.h>
+#include <sys/socket.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <sys/uio.h>
+#include <sys/un.h>
+#include <sys/wait.h>
 
 
 /* Since STREAMS are not supported in the standard Linux kernel and
index 3efbb724f83794850e37e1f49f9705ceb316ae12..e1b1ff90cf4c3e1f4f664d3b6b060e68cbcd401f 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <errno.h>
 #include <pthread.h>
+#include <signal.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/types.h>
index f1e77f6b1080c4e7fcc0567696f661d4d7edf4e8..3883a471ed9140f22efe9d6bd15c63fd0991e88d 100644 (file)
@@ -1,5 +1,6 @@
 #include <errno.h>
 #include <pthread.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index 2d7927b7c29b36eb20cc07073a66179307d37cbd..04487f61422aae52ac19826858ca595d9ec6be0b 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <errno.h>
 #include <pthread.h>
+#include <signal.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
index 73937fe5d6c5816e009d7613e987a795c691dac9..89919bbab935e934b6bfe93f3ef0136222d857e4 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <errno.h>
 #include <pthread.h>
+#include <signal.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
index d4646ac89fdb54728c229160dc73b2e91cb2d9cf..1e128d0bc5cee727eac7785958252591aea93224 100644 (file)
@@ -30,7 +30,7 @@ __BEGIN_DECLS
 #include <bits/types/pid_t.h>
 
 #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-# include <signal.h>
+# include <bits/types/siginfo_t.h>
 #endif
 
 #if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8
index 17021acaeaae61bb75be19ff6426685b02a0ca5b..c46282dcb0c46910c124f9c98e80cf115b87de01 100644 (file)
@@ -25,6 +25,7 @@
 #include <gnu/lib-names.h>
 #include <netdb.h>
 #include <resolv/resolv_context.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <support/capture_subprocess.h>
index c35580b9effc2628e0c3f4cc957a4aa3d0135e38..6e83a8234e145753b1340d3d3933b2e13c944f14 100644 (file)
 #include <errno.h>
 #include <fcntl.h>
 #include <mqueue.h>
+#include <signal.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/wait.h>
 #include <time.h>
 #include <unistd.h>
-#include <stdint.h>
+#include <sys/wait.h>
 #include "tst-mqueue.h"
 
 static int
index 77999d8c6f3aeca55420b88d52d29f328a73d086..48a21cde0f913aa7ff50ffd2974d2ee0d98b71b6 100755 (executable)
@@ -531,15 +531,15 @@ HEADER_ALLOWED_INCLUDES = {
     #           sys/sem.h -> sys/ipc.h
     #           sys/shm.h -> sys/ipc.h
     #           sys/time.h -> sys/select.h (effectively)
-    # allowed:  sys/wait.h -> signal.h
     "sys/msg.h":                   [ "sys/ipc.h" ],
     "sys/sem.h":                   [ "sys/ipc.h" ],
     "sys/shm.h":                   [ "sys/ipc.h" ],
     "sys/time.h":                  [ "sys/select.h" ],
+    # necessary for backward compatibility with BSD
     "sys/types.h":                 [ "endian.h" ],
+
     "sys/uio.h":                   [ "sys/types.h" ],
     "sys/un.h":                    [ "string.h" ],
-    "sys/wait.h":                  [ "signal.h" ],
 
     # POSIX networking headers
     # allowed: netdb.h -> netinet/in.h
@@ -593,8 +593,7 @@ HEADER_ALLOWED_INCLUDES = {
     "sys/ioctl.h":                 [ "sys/ttydefaults.h" ],
     "sys/mount.h":                 [ "sys/ioctl.h" ],
     "sys/mtio.h":                  [ "sys/ioctl.h", "sys/types.h" ],
-    "sys/param.h":                 [ "endian.h", "limits.h", "signal.h",
-                                     "sys/types.h" ],
+    "sys/param.h":                 [ "endian.h", "limits.h", "sys/types.h" ],
     "sys/platform/ppc.h":          [ "stdint.h" ],
     "sys/procfs.h":                [ "sys/time.h", "sys/types.h",
                                      "sys/user.h" ],
index 67bbc1e8ae4d935c9f4177d9e12d5d6f8cb7d851..86442fefe0fe94de4df67429385b993786c29ead 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <errno.h>
+#include <getopt.h>
+#include <limits.h>
+#include <paths.h>
+#include <signal.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include <array_length.h>
 #include <support/capture_subprocess.h>
 #include <support/check.h>
 #include <support/support.h>
 #include <support/temp_file.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <paths.h>
-#include <getopt.h>
-#include <limits.h>
-#include <errno.h>
-#include <array_length.h>
 
 /* Nonzero if the program gets called via 'exec'.  */
 static int restart;
@@ -273,7 +275,8 @@ do_multiple_tests (enum test_type type)
                   .out = random_string (lengths[length_idx_stdout]),
                   .err = random_string (lengths[length_idx_stderr]),
                   .write_mode = write_mode,
-                  .signal = signal * SIGTERM, /* 0 or SIGTERM.  */
+                  .signal = signal *
+                  SIGTERM, /* 0 or SIGTERM.  */
                   .status = status * 3,       /* 0 or 3.  */
                 };
               TEST_VERIFY (strlen (test.out) == lengths[length_idx_stdout]);
index c288664b65f54df308642d12621186d53a991254..25875ce051dcaac09c7167a6f729ba1b09ce2869 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
 #ifndef _SYS_PARAM_H
 # error "Never use <bits/param.h> directly; include <sys/param.h> instead."
 #endif
 
 #include <bits/mach/param.h>
 
-/* This file is deprecated and is provided only for compatibility with
-   Unix systems.  It is unwise to include this file on programs which
-   are intended only for GNU systems.
-
-   Parts from:
-
- * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
+/* Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -85,3 +82,5 @@
 
 #define        FSHIFT  11              /* Bits to right of fixed binary point.  */
 #define FSCALE (1<<FSHIFT)
+
+#endif /* bits/param.h */
index 2a7d138fff216ecf3c31e3ab1b80d69a8c1ce42d..aa23a4b209202249d16858993e0928dae5039c53 100644 (file)
@@ -36,7 +36,6 @@ test-xfail-UNIX98/aio.h/conform = yes
 test-xfail-UNIX98/ftw.h/conform = yes
 test-xfail-UNIX98/mqueue.h/conform = yes
 test-xfail-UNIX98/netinet/in.h/conform = yes
-test-xfail-UNIX98/sys/wait.h/conform = yes
 test-xfail-UNIX98/sys/sem.h/conform = yes
 test-xfail-UNIX98/sys/uio.h/conform = yes
 test-xfail-UNIX98/sys/socket.h/conform = yes
@@ -51,7 +50,6 @@ test-xfail-POSIX2008/regex.h/conform = yes
 test-xfail-POSIX2008/aio.h/conform = yes
 test-xfail-POSIX2008/mqueue.h/conform = yes
 test-xfail-POSIX2008/netinet/in.h/conform = yes
-test-xfail-POSIX2008/sys/wait.h/conform = yes
 test-xfail-POSIX2008/sys/socket.h/conform = yes
 test-xfail-POSIX2008/sys/types.h/conform = yes
 test-xfail-POSIX2008/arpa/inet.h/conform = yes
@@ -64,7 +62,6 @@ test-xfail-XOPEN2K/aio.h/conform = yes
 test-xfail-XOPEN2K/ftw.h/conform = yes
 test-xfail-XOPEN2K/mqueue.h/conform = yes
 test-xfail-XOPEN2K/netinet/in.h/conform = yes
-test-xfail-XOPEN2K/sys/wait.h/conform = yes
 test-xfail-XOPEN2K/sys/sem.h/conform = yes
 test-xfail-XOPEN2K/sys/uio.h/conform = yes
 test-xfail-XOPEN2K/sys/socket.h/conform = yes
@@ -80,7 +77,6 @@ test-xfail-XOPEN2K8/aio.h/conform = yes
 test-xfail-XOPEN2K8/ftw.h/conform = yes
 test-xfail-XOPEN2K8/mqueue.h/conform = yes
 test-xfail-XOPEN2K8/netinet/in.h/conform = yes
-test-xfail-XOPEN2K8/sys/wait.h/conform = yes
 test-xfail-XOPEN2K8/sys/sem.h/conform = yes
 test-xfail-XOPEN2K8/sys/uio.h/conform = yes
 test-xfail-XOPEN2K8/sys/socket.h/conform = yes
index 80d6f9ff2c75c369bd26dd9ceb05bd15284fc9d2..daa4b8ebafe0913ff3693e19edee805e519c1aa9 100644 (file)
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_MACH_PARAM_H
+#define _BITS_MACH_PARAM_H 1
+
 #ifndef _SYS_PARAM_H
 # error "Never use <bits/mach/param.h> directly; include <sys/param.h> instead."
 #endif
@@ -23,3 +26,5 @@
 #ifndef EXEC_PAGESIZE
 #define EXEC_PAGESIZE  4096
 #endif
+
+#endif
index a8d47af038e98fb3077305a161993a37e810f295..292782f7a604f52cb0fe3937c00d2c21a9edd4d9 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef _BITS_SIGNUM_H
 #define _BITS_SIGNUM_H 1
 
-#ifndef _SIGNAL_H
+#if !defined _SIGNAL_H && !defined _SYS_PARAM_H
 #error "Never include <bits/signum.h> directly; use <signal.h> instead."
 #endif
 
index 63add0e3dbcd2dcef146692b9aff21fe3deefc01..1cfa208dbe568205420a751714f03f59f4a530a2 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef _BITS_SIGNUM_H
 #define _BITS_SIGNUM_H 1
 
-#ifndef _SIGNAL_H
+#if !defined _SIGNAL_H && !defined _SYS_PARAM_H
 #error "Never include <bits/signum.h> directly; use <signal.h> instead."
 #endif
 
index 1ed5dbd70c4613d555349da0d379fa77cf22aa5b..1557a1dc8f9b387aa8c112a3a9437aaa6aeb8f7d 100644 (file)
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
 #ifndef _SYS_PARAM_H
 # error "Never use <bits/param.h> directly; include <sys/param.h> instead."
 #endif
@@ -40,3 +43,5 @@
    and NCARGS anyway.  */
 #define NOFILE         256
 #define        NCARGS          131072
+
+#endif /* bits/param.h */
index 423fd8be702495819e22530cabdbe66a7b31be5c..19646fedf80ee898268f5443fd60a5ecc20d668f 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef _BITS_SIGNUM_H
 #define _BITS_SIGNUM_H 1
 
-#ifndef _SIGNAL_H
+#if !defined _SIGNAL_H && !defined _SYS_PARAM_H
 #error "Never include <bits/signum.h> directly; use <signal.h> instead."
 #endif
 
index 2210304e37261800c7feeb603bb424ca3e2c4692..8c9441e452a03d9be261b14c5accdafe13a12ae3 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef _BITS_SIGNUM_H
 #define _BITS_SIGNUM_H 1
 
-#ifndef _SIGNAL_H
+#if !defined _SIGNAL_H && !defined _SYS_PARAM_H
 #error "Never include <bits/signum.h> directly; use <signal.h> instead."
 #endif
 
index f5a5e7b4cd8a13acddfb4e371e8dedd3390ee739..05363d90f9f4c27b0a8ff394ed54e136497d6115 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef _BITS_SIGNUM_H
 #define _BITS_SIGNUM_H 1
 
-#ifndef _SIGNAL_H
+#if !defined _SIGNAL_H && !defined _SYS_PARAM_H
 #error "Never include <bits/signum.h> directly; use <signal.h> instead."
 #endif
 
index 953588929ab5308345323398090259736065e5bf..adbe4271694ed813586874bc9cc7a25ac26c3f00 100644 (file)
@@ -16,6 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index 40fb39a4350e89e86ca035541ac167613a405e82..42e721234ed8e6aeb09682a6abd76fe6696ba4eb 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef _BITS_SIGNUM_H
 #define _BITS_SIGNUM_H 1
 
-#ifndef _SIGNAL_H
+#if !defined _SIGNAL_H && !defined _SYS_PARAM_H
 #error "Never include <bits/signum.h> directly; use <signal.h> instead."
 #endif
 
index 261ef9ed6f63f511454c445949f596b197a99524..2fe303de729ad476612dfce58862f9c51280cc67 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #include <sched.h>
+#include <signal.h>
+#include <stackinfo.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/wait.h>
 #include <unistd.h>
+#include <sys/wait.h>
 #include <tst-stack-align.h>
-#include <stackinfo.h>
 
 static int
 f (void *arg)