chiark / gitweb /
Revert "Block signals except during the event loop."
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 4 Jan 2017 00:43:15 +0000 (00:43 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 4 Jan 2017 00:48:56 +0000 (00:48 +0000)
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 <ijackson@chiark.greenend.org.uk>
events.c
events.h
twm.c

index 7e8c7af8eba0f8d4ad2544278073a4d5307d3249..28e1e29b7f4925e1f1d9f1946f0abfa2163ce980 100644 (file)
--- a/events.c
+++ b/events.c
  *
  ***********************************************************************/
 
-#define _GNU_SOURCE /* for ppoll */
 #include <stdio.h>
 #include <string.h>
-#include <signal.h>
-#include <poll.h>
-#include <errno.h>
 #include "twm.h"
 #include <X11/Xatom.h>
 #include "add_window.h"
@@ -364,35 +360,6 @@ Bool DispatchEvent ()
 
 \f
 
-/***********************************************************************
- *
- *  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 ();
        }
 }
index 6c447df1fc20d6e915878139fc383bf384704c8c..8d4230455681d57de0cdf9cad089aaa1403a5cfb 100644 (file)
--- 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 edb040a322fe10acf9f8f1e4564cda6aed7af903..1402eee38f3716b2bfc6449a9310f06fa9760657 100644 (file)
--- 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 = "./";