From 6178b1c91cfc9e860914acc6f0be2f2d2e07a124 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 7 Jun 2016 15:52:11 -0400 Subject: [PATCH] dix: Use OsSignal() not signal() As the man page for the latter states: The effects of signal() in a multithreaded process are unspecified. We already have an interface to call sigaction() instead, use it. Signed-off-by: Adam Jackson Reviewed-by: Keith Packard --- Xext/shm.c | 5 ++--- Xext/xf86bigfont.c | 6 ++---- hw/dmx/input/lnx-keyboard.c | 5 ++--- hw/kdrive/ephyr/ephyr.h | 1 - hw/kdrive/linux/linux.c | 1 - hw/kdrive/src/kdrive.c | 2 -- hw/kdrive/src/kinput.c | 1 - hw/xfree86/common/xf86Init.c | 18 +++++++++--------- hw/xfree86/os-support/bsd/bsd_init.c | 2 +- hw/xfree86/os-support/linux/lnx_init.c | 2 +- hw/xfree86/os-support/shared/VTsw_usl.c | 2 +- hw/xfree86/parser/write.c | 5 ++--- include/globals.h | 2 -- os/utils.c | 4 ++-- 14 files changed, 22 insertions(+), 34 deletions(-) diff --git a/Xext/shm.c b/Xext/shm.c index b359a9035..0a44b7611 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -153,7 +153,6 @@ static ShmFuncs fbFuncs = { fbShmCreatePixmap, NULL }; } #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__) -#include static Bool badSysCall = FALSE; @@ -170,7 +169,7 @@ CheckForShmSyscall(void) int shmid = -1; /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */ - oldHandler = signal(SIGSYS, SigSysHandler); + oldHandler = OsSignal(SIGSYS, SigSysHandler); badSysCall = FALSE; shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT); @@ -183,7 +182,7 @@ CheckForShmSyscall(void) /* Allocation failed */ badSysCall = TRUE; } - signal(SIGSYS, oldHandler); + OsSignal(SIGSYS, oldHandler); return !badSysCall; } diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index 95b537170..97596ea5f 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -96,8 +96,6 @@ static Bool badSysCall = FALSE; #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__) -#include - static void SigSysHandler(int signo) { @@ -111,7 +109,7 @@ CheckForShmSyscall(void) int shmid = -1; /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */ - oldHandler = signal(SIGSYS, SigSysHandler); + oldHandler = OsSignal(SIGSYS, SigSysHandler); badSysCall = FALSE; shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT); @@ -123,7 +121,7 @@ CheckForShmSyscall(void) /* Allocation failed */ badSysCall = TRUE; } - signal(SIGSYS, oldHandler); + OsSignal(SIGSYS, oldHandler); return !badSysCall; } diff --git a/hw/dmx/input/lnx-keyboard.c b/hw/dmx/input/lnx-keyboard.c index 0aa62f452..2a5ce7947 100644 --- a/hw/dmx/input/lnx-keyboard.c +++ b/hw/dmx/input/lnx-keyboard.c @@ -158,7 +158,6 @@ #include #include #include -#include #include #include #include @@ -505,7 +504,7 @@ kbdLinuxVTSignalHandler(int sig) { myPrivate *priv = PRIV; - signal(sig, kbdLinuxVTSignalHandler); + OsSignal(sig, kbdLinuxVTSignalHandler); if (priv) { ioctl(priv->fd, VT_RELDISP, VT_ACKACQ); priv->switched = !priv->switched; @@ -537,7 +536,7 @@ kbdLinuxActivate(int fd, int vtno, int setSig) VT.acqsig = SIGUSR1; if (ioctl(fd, VT_SETMODE, &VT)) FATAL0("kbdLinuxActivate: VT_SETMODE VT_PROCESS failed\n"); - signal(SIGUSR1, kbdLinuxVTSignalHandler); + OsSignal(SIGUSR1, kbdLinuxVTSignalHandler); } return Success; } diff --git a/hw/kdrive/ephyr/ephyr.h b/hw/kdrive/ephyr/ephyr.h index f5015f661..7723bf194 100644 --- a/hw/kdrive/ephyr/ephyr.h +++ b/hw/kdrive/ephyr/ephyr.h @@ -27,7 +27,6 @@ #define _EPHYR_H_ #include #include -#include #include #include diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c index a52bdefc9..76daaf23e 100644 --- a/hw/kdrive/linux/linux.c +++ b/hw/kdrive/linux/linux.c @@ -25,7 +25,6 @@ #endif #include "kdrive.h" #include -#include #include #include #include diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index 52bea5a04..f02d8262b 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -43,8 +43,6 @@ #include #endif -#include - #if defined(CONFIG_UDEV) || defined(CONFIG_HAL) #include #endif diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 4119b083b..c2fc7bb8c 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -32,7 +32,6 @@ #if HAVE_X11_XF86KEYSYM_H #include #endif -#include #include #ifdef __sun #include /* needed for FNONBLOCK & FASYNC */ diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 323ac11fc..93c0d74be 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -308,16 +308,16 @@ InstallSignalHandlers(void) OsRegisterSigWrapper(xf86SigWrapper); } else { - signal(SIGSEGV, SIG_DFL); - signal(SIGILL, SIG_DFL); + OsSignal(SIGSEGV, SIG_DFL); + OsSignal(SIGILL, SIG_DFL); #ifdef SIGEMT - signal(SIGEMT, SIG_DFL); + OsSignal(SIGEMT, SIG_DFL); #endif - signal(SIGFPE, SIG_DFL); - signal(SIGBUS, SIG_DFL); - signal(SIGSYS, SIG_DFL); - signal(SIGXCPU, SIG_DFL); - signal(SIGXFSZ, SIG_DFL); + OsSignal(SIGFPE, SIG_DFL); + OsSignal(SIGBUS, SIG_DFL); + OsSignal(SIGSYS, SIG_DFL); + OsSignal(SIGXCPU, SIG_DFL); + OsSignal(SIGXFSZ, SIG_DFL); } } @@ -924,7 +924,7 @@ OsVendorInit(void) { static Bool beenHere = FALSE; - signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */ + OsSignal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */ if (!beenHere) { umask(022); diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index 38dfde11a..0d5d3c87c 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -269,7 +269,7 @@ xf86OpenConsole() "xf86OpenConsole: VT_WAITACTIVE failed\n"); } - signal(SIGUSR1, xf86VTRequest); + OsSignal(SIGUSR1, xf86VTRequest); vtmode.mode = VT_PROCESS; vtmode.relsig = SIGUSR1; diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c index 1ed213c00..d3a53ea83 100644 --- a/hw/xfree86/os-support/linux/lnx_init.c +++ b/hw/xfree86/os-support/linux/lnx_init.c @@ -247,7 +247,7 @@ xf86OpenConsole(void) FatalError("xf86OpenConsole: VT_GETMODE failed %s\n", strerror(errno)); - signal(SIGUSR1, xf86VTRequest); + OsSignal(SIGUSR1, xf86VTRequest); VT.mode = VT_PROCESS; VT.relsig = SIGUSR1; diff --git a/hw/xfree86/os-support/shared/VTsw_usl.c b/hw/xfree86/os-support/shared/VTsw_usl.c index f20106c90..64402616e 100644 --- a/hw/xfree86/os-support/shared/VTsw_usl.c +++ b/hw/xfree86/os-support/shared/VTsw_usl.c @@ -43,7 +43,7 @@ void xf86VTRequest(int sig) { - signal(sig, (void (*)(int)) xf86VTRequest); + OsSignal(sig, (void (*)(int)) xf86VTRequest); xf86Info.vtRequestsPending = TRUE; return; } diff --git a/hw/xfree86/parser/write.c b/hw/xfree86/parser/write.c index 9a24dd6cf..122e96730 100644 --- a/hw/xfree86/parser/write.c +++ b/hw/xfree86/parser/write.c @@ -63,7 +63,6 @@ #include #include #include -#include #include #if defined(HAVE_SETEUID) && defined(_POSIX_SAVED_IDS) && _POSIX_SAVED_IDS > 0 @@ -141,7 +140,7 @@ xf86writeConfigFile(const char *filename, XF86ConfigPtr cptr) void (*csig) (int); /* Need to fork to change ruid without loosing euid */ - csig = signal(SIGCHLD, SIG_DFL); + csig = OsSignal(SIGCHLD, SIG_DFL); switch ((pid = fork())) { case -1: ErrorF("xf86writeConfigFile(): fork failed (%s)\n", @@ -159,7 +158,7 @@ xf86writeConfigFile(const char *filename, XF86ConfigPtr cptr) p = waitpid(pid, &status, 0); } while (p == -1 && errno == EINTR); } - signal(SIGCHLD, csig); + OsSignal(SIGCHLD, csig); if (p != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0) return 1; /* success */ else diff --git a/include/globals.h b/include/globals.h index 858c9a375..693bdf4f2 100644 --- a/include/globals.h +++ b/include/globals.h @@ -2,8 +2,6 @@ #ifndef _XSERV_GLOBAL_H_ #define _XSERV_GLOBAL_H_ -#include - #include "window.h" /* for WindowPtr */ #include "extinit.h" diff --git a/os/utils.c b/os/utils.c index 086fe4fcd..5871ef8de 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1395,7 +1395,7 @@ System(const char *command) if (!command) return 1; - csig = signal(SIGCHLD, SIG_DFL); + csig = OsSignal(SIGCHLD, SIG_DFL); if (csig == SIG_ERR) { perror("signal"); return -1; @@ -1420,7 +1420,7 @@ System(const char *command) } - if (signal(SIGCHLD, csig) == SIG_ERR) { + if (OsSignal(SIGCHLD, csig) == SIG_ERR) { perror("signal"); return -1; }