From 37bc5cdd0e31fd9c8712c0bd88039dd474be4418 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 12 Apr 2015 23:05:48 -0500 Subject: Fix long-standing inverted signal mask in kdesktop_lock initial sigsuspend Prevent helper thread termination signal from errantly being handled by main thread --- kdesktop/lock/lockprocess.cc | 7 ++++ kdesktop/lock/main.cc | 93 +++++++++++++++++++++++--------------------- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/kdesktop/lock/lockprocess.cc b/kdesktop/lock/lockprocess.cc index da12bd46c..a4a2badd3 100644 --- a/kdesktop/lock/lockprocess.cc +++ b/kdesktop/lock/lockprocess.cc @@ -2842,6 +2842,13 @@ void ControlPipeHandlerObject::run(void) { mThreadID = pthread_self(); mRunning = true; + sigset_t new_mask; + sigemptyset(&new_mask); + sigaddset(&new_mask, SIGUSR1); + + // Unblock SIGUSR1 + pthread_sigmask(SIG_UNBLOCK, &new_mask, NULL); + int display_number = atoi(TQString(XDisplayString(tqt_xdisplay())).replace(":","").ascii()); if (display_number < 0) { diff --git a/kdesktop/lock/main.cc b/kdesktop/lock/main.cc index bafa02539..c1b1da2f0 100644 --- a/kdesktop/lock/main.cc +++ b/kdesktop/lock/main.cc @@ -378,52 +378,52 @@ int main( int argc, char **argv ) if (args->isSet( "internal" )) { kdesktop_pid = atoi(args->getOption( "internal" )); - while (signalled_run == FALSE) { - sigset_t new_mask; - sigset_t orig_mask; - struct sigaction act; - - in_internal_mode = TRUE; - - // handle SIGUSR1 - act.sa_handler= sigusr1_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGUSR1); - act.sa_flags = 0; - sigaction(SIGUSR1, &act, 0L); - // handle SIGUSR2 - act.sa_handler= sigusr2_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGUSR2); - act.sa_flags = 0; - sigaction(SIGUSR2, &act, 0L); - // handle SIGWINCH (an ersatz SIGUSR3) - act.sa_handler= sigusr3_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGWINCH); - act.sa_flags = 0; - sigaction(SIGWINCH, &act, 0L); - // handle SIGTTIN (an ersatz SIGUSR4) - act.sa_handler= sigusr4_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGTTIN); - act.sa_flags = 0; - sigaction(SIGTTIN, &act, 0L); - // handle SIGTTOU (an ersatz SIGUSR5) - act.sa_handler= sigusr5_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGTTOU); - act.sa_flags = 0; - sigaction(SIGTTOU, &act, 0L); - - // initialize the signal masks - sigfillset(&new_mask); - sigdelset(&new_mask,SIGUSR1); - sigdelset(&new_mask,SIGUSR2); - sigdelset(&new_mask,SIGWINCH); - sigdelset(&new_mask,SIGTTIN); - sigdelset(&new_mask,SIGTTOU); + sigset_t new_mask; + sigset_t orig_mask; + struct sigaction act; + + in_internal_mode = TRUE; + + // handle SIGUSR1 + act.sa_handler= sigusr1_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGUSR1); + act.sa_flags = 0; + sigaction(SIGUSR1, &act, 0L); + // handle SIGUSR2 + act.sa_handler= sigusr2_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGUSR2); + act.sa_flags = 0; + sigaction(SIGUSR2, &act, 0L); + // handle SIGWINCH (an ersatz SIGUSR3) + act.sa_handler= sigusr3_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGWINCH); + act.sa_flags = 0; + sigaction(SIGWINCH, &act, 0L); + // handle SIGTTIN (an ersatz SIGUSR4) + act.sa_handler= sigusr4_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGTTIN); + act.sa_flags = 0; + sigaction(SIGTTIN, &act, 0L); + // handle SIGTTOU (an ersatz SIGUSR5) + act.sa_handler= sigusr5_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGTTOU); + act.sa_flags = 0; + sigaction(SIGTTOU, &act, 0L); + + // initialize the signal masks + sigemptyset(&new_mask); + sigaddset(&new_mask,SIGUSR1); + sigaddset(&new_mask,SIGUSR2); + sigaddset(&new_mask,SIGWINCH); + sigaddset(&new_mask,SIGTTIN); + sigaddset(&new_mask,SIGTTOU); + while (signalled_run == FALSE) { // let kdesktop know the saver process is ready if (kill(kdesktop_pid, SIGTTIN) < 0) { // The controlling kdesktop process probably died. Commit suicide... @@ -448,6 +448,9 @@ int main( int argc, char **argv ) // Reenable reception of X11 events on the root window XSelectInput( tqt_xdisplay(), tqt_xrootwin(), rootAttr.your_event_mask ); } + + // Block reception of all signals in this thread + sigprocmask(SIG_BLOCK, &new_mask, NULL); } // (re)load settings here so that they actually reflect reality -- cgit v1.2.1