From e4a2a28e51f9a4f57ef146406579d72be894a520 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 4 Jan 2017 00:43:15 +0000 Subject: [PATCH] Revert "Block signals except during the event loop." This approach leaks the blocking signal mask into subprocesses, It could be fixed by finding all the places where we fork and exec, but vtwm likes to use system and popen, which are hard to adjust since there is no hook which runs in the child. (We could use pthread_atfork but then we'd have to link against pthreads...) This reverts commit 91b2ee084430dbe5d81d32d15e06b53d931514d9. (apart from the changelog entry) Signed-off-by: Ian Jackson --- events.c | 48 +----------------------------------------------- events.h | 4 ---- twm.c | 6 ------ 3 files changed, 1 insertion(+), 57 deletions(-) diff --git a/events.c b/events.c index 7e8c7af..28e1e29 100644 --- a/events.c +++ b/events.c @@ -36,12 +36,8 @@ * ***********************************************************************/ -#define _GNU_SOURCE /* for ppoll */ #include #include -#include -#include -#include #include "twm.h" #include #include "add_window.h" @@ -364,35 +360,6 @@ Bool DispatchEvent () -/*********************************************************************** - * - * Procedures: - * BlockSignalsAddToList required for every signal we handle - * BlockSignals } signals must be blocked except in - * UnBlockSignals } the relevant bit of the event loop - * - *********************************************************************** - */ - -static _Bool blocksignalslist_initialised; -static sigset_t blocksignalslist; - -void -BlockSignalsAddToList(sig) - int sig; -{ - if (!blocksignalslist_initialised++) - sigemptyset(&blocksignalslist); - - sigaddset(&blocksignalslist, sig); -} - -void -BlockSignals() -{ - sigprocmask(SIG_BLOCK, &blocksignalslist, NULL); -} - /*********************************************************************** * * Procedure: @@ -404,12 +371,6 @@ BlockSignals() void HandleEvents() { - struct pollfd pfd; - pfd.fd = ConnectionNumber(dpy); - pfd.events = POLLIN|POLLPRI; - sigset_t emptyset; - sigemptyset(&emptyset); - while (TRUE) { if (enter_flag && !QLength(dpy)) { @@ -423,14 +384,7 @@ HandleEvents() InstallWindowColormaps(ColormapNotify, (TwmWindow *) NULL); } WindowMoved = FALSE; - while (!XCheckMaskEvent(dpy, -1 /* wot no AllEventMask */, &Event)) { - int r; - r = ppoll(&pfd, 1, 0, &emptyset); - if (r<0 && errno!=EINTR) { - perror("vtwm: poll failed"); - exit(-1); - } - } + XNextEvent(dpy, &Event); (void) DispatchEvent (); } } diff --git a/events.h b/events.h index 6c447df..8d42304 100644 --- a/events.h +++ b/events.h @@ -77,10 +77,6 @@ extern void InstallWindowColormaps(); extern void RedoDoorName(); /* djhjr - 2/28/99 */ extern void RedoListWindow(); /* djhjr - 3/1/99 */ -extern void BlockSignalsAddToList(); -extern void BlockSignals(); -extern void UnblockSignals(); - extern event_proc EventHandler[]; extern Window DragWindow; extern int origDragX; diff --git a/twm.c b/twm.c index edb040a..1402eee 100644 --- a/twm.c +++ b/twm.c @@ -258,15 +258,12 @@ main(argc, argv, environ) /* djhjr - 6/22/01 */ #ifndef NO_SOUND_SUPPORT #define sounddonehandler(sig) \ - BlockSignalsAddToList(sig); \ if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, PlaySoundDone) #else #define sounddonehandler(sig) \ - BlockSignalsAddToList(sig); \ if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, Done) #endif #define donehandler(sig) \ - BlockSignalsAddToList(sig); \ if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, Done) sounddonehandler (SIGINT); @@ -285,11 +282,8 @@ main(argc, argv, environ) #undef donehandler /* djhjr - 7/31/98 */ - BlockSignalsAddToList(SIGUSR1); signal (SIGUSR1, QueueRestartVtwm); - BlockSignals(); - Home = getenv("HOME"); if (Home == NULL) Home = "./"; -- 2.30.2