emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117201: Don't let SIGINT handling block SIGCHLD ind


From: Paul Eggert
Subject: [Emacs-diffs] trunk r117201: Don't let SIGINT handling block SIGCHLD indefinitely.
Date: Fri, 30 May 2014 04:12:13 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117201
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/17561
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Thu 2014-05-29 21:12:08 -0700
message:
  Don't let SIGINT handling block SIGCHLD indefinitely.
  
  * atimer.c (block_atimers):
  * callproc.c (block_child_signal): Block SIGINT too;
  otherwise, its handler might now unblock signals that it shouldn't.
  * keyboard.c (read_char): Clear signal mask, since we may
  be in a SIGINT handler, and many signals may be masked.
  * keyboard.c (handle_interrupt):
  * sysdep.c (handle_arith_signal):
  Clear signal mask instead of just unblocking the signal that
  was received, since several signals may be blocked at this point.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/atimer.c                   atimer.c-20091113204419-o5vbwnq5f7feedwu-1759
  src/callproc.c                 callproc.c-20091113204419-o5vbwnq5f7feedwu-248
  src/keyboard.c                 keyboard.c-20091113204419-o5vbwnq5f7feedwu-449
  src/sysdep.c                   sysdep.c-20091113204419-o5vbwnq5f7feedwu-448
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-05-29 19:16:32 +0000
+++ b/src/ChangeLog     2014-05-30 04:12:08 +0000
@@ -1,3 +1,16 @@
+2014-05-30  Paul Eggert  <address@hidden>
+
+       Don't let SIGINT handling block SIGCHLD indefinitely (Bug#17561).
+       * atimer.c (block_atimers):
+       * callproc.c (block_child_signal): Block SIGINT too;
+       otherwise, its handler might now unblock signals that it shouldn't.
+       * keyboard.c (read_char): Clear signal mask, since we may
+       be in a SIGINT handler, and many signals may be masked.
+       * keyboard.c (handle_interrupt):
+       * sysdep.c (handle_arith_signal):
+       Clear signal mask instead of just unblocking the signal that
+       was received, since several signals may be blocked at this point.
+
 2014-05-29  Eli Zaretskii  <address@hidden>
 
        * Makefile.in (TEMACS_POST_LINK): Remove target.

=== modified file 'src/atimer.c'
--- a/src/atimer.c      2014-03-25 14:43:26 +0000
+++ b/src/atimer.c      2014-05-30 04:12:08 +0000
@@ -55,6 +55,7 @@
   sigset_t blocked;
   sigemptyset (&blocked);
   sigaddset (&blocked, SIGALRM);
+  sigaddset (&blocked, SIGINT);
   pthread_sigmask (SIG_BLOCK, &blocked, oldset);
 }
 static void
@@ -404,7 +405,6 @@
 void
 init_atimer (void)
 {
-  struct sigaction action;
 #ifdef HAVE_ITIMERSPEC
   struct sigevent sigev;
   sigev.sigev_notify = SIGEV_SIGNAL;
@@ -413,7 +413,9 @@
   alarm_timer_ok = timer_create (CLOCK_REALTIME, &sigev, &alarm_timer) == 0;
 #endif
   free_atimers = stopped_atimers = atimers = NULL;
-  /* pending_signals is initialized in init_keyboard.*/
+
+  /* pending_signals is initialized in init_keyboard.  */
+  struct sigaction action;
   emacs_sigaction_init (&action, handle_alarm_signal);
   sigaction (SIGALRM, &action, 0);
 }

=== modified file 'src/callproc.c'
--- a/src/callproc.c    2014-04-16 19:43:46 +0000
+++ b/src/callproc.c    2014-05-30 04:12:08 +0000
@@ -115,6 +115,7 @@
   sigset_t blocked;
   sigemptyset (&blocked);
   sigaddset (&blocked, SIGCHLD);
+  sigaddset (&blocked, SIGINT);
   pthread_sigmask (SIG_BLOCK, &blocked, oldset);
 }
 

=== modified file 'src/keyboard.c'
--- a/src/keyboard.c    2014-05-28 08:00:10 +0000
+++ b/src/keyboard.c    2014-05-30 04:12:08 +0000
@@ -2664,6 +2664,7 @@
       /* We must have saved the outer value of getcjmp here,
         so restore it now.  */
       restore_getcjmp (save_jump);
+      pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
       unbind_to (jmpcount, Qnil);
       XSETINT (c, quit_char);
       internal_last_event_frame = selected_frame;
@@ -10323,9 +10324,6 @@
 handle_interrupt (bool in_signal_handler)
 {
   char c;
-  sigset_t blocked;
-  sigemptyset (&blocked);
-  sigaddset (&blocked, SIGINT);
 
   cancel_echoing ();
 
@@ -10337,6 +10335,9 @@
          /* If SIGINT isn't blocked, don't let us be interrupted by
             a SIGINT.  It might be harmful due to non-reentrancy
             in I/O functions.  */
+         sigset_t blocked;
+         sigemptyset (&blocked);
+         sigaddset (&blocked, SIGINT);
          pthread_sigmask (SIG_BLOCK, &blocked, 0);
        }
 
@@ -10421,7 +10422,7 @@
          struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
 
          immediate_quit = 0;
-         pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
+         pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
          saved = gl_state;
          GCPRO4 (saved.object, saved.global_code,
                  saved.current_syntax_table, saved.old_prop);
@@ -10442,7 +10443,7 @@
         }
     }
 
-  pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
+  pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
 
 /* TODO: The longjmp in this call throws the NS event loop integration off,
          and it seems to do fine without this.  Probably some attention

=== modified file 'src/sysdep.c'
--- a/src/sysdep.c      2014-04-16 19:43:46 +0000
+++ b/src/sysdep.c      2014-05-30 04:12:08 +0000
@@ -1645,10 +1645,7 @@
 static _Noreturn void
 handle_arith_signal (int sig)
 {
-  sigset_t blocked;
-  sigemptyset (&blocked);
-  sigaddset (&blocked, sig);
-  pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
+  pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
   xsignal0 (Qarith_error);
 }
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]