emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r103236: Make sure SIGPIPE is reset i


From: Andreas Schwab
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103236: Make sure SIGPIPE is reset in child processes
Date: Sat, 12 Feb 2011 19:53:24 +0100
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 103236
committer: Andreas Schwab <address@hidden>
branch nick: emacs
timestamp: Sat 2011-02-12 19:53:24 +0100
message:
  Make sure SIGPIPE is reset in child processes
  
  * process.c (create_process): Reset SIGPIPE handler in the child.
  * callproc.c (Fcall_process): Likewise.  (Bug#5238)
modified:
  src/ChangeLog
  src/callproc.c
  src/process.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-02-12 15:48:10 +0000
+++ b/src/ChangeLog     2011-02-12 18:53:24 +0000
@@ -1,3 +1,8 @@
+2011-02-12  Andreas Schwab  <address@hidden>
+
+       * process.c (create_process): Reset SIGPIPE handler in the child.
+       * callproc.c (Fcall_process): Likewise.  (Bug#5238)
+
 2011-02-12  Eli Zaretskii  <address@hidden>
 
        * xdisp.c <this_line_min_pos>: New variable.

=== modified file 'src/callproc.c'
--- a/src/callproc.c    2011-02-07 05:06:59 +0000
+++ b/src/callproc.c    2011-02-12 18:53:24 +0000
@@ -445,6 +445,11 @@
     register char **save_environ = environ;
     register int fd1 = fd[1];
     int fd_error = fd1;
+#ifdef HAVE_WORKING_VFORK
+    sigset_t procmask;
+    sigset_t blocked;
+    struct sigaction sigpipe_action;
+#endif
 
 #if 0  /* Some systems don't have sigblock.  */
     mask = sigblock (sigmask (SIGCHLD));
@@ -525,6 +530,18 @@
     pid = child_setup (filefd, fd1, fd_error, (char **) new_argv,
                       0, current_dir);
 #else  /* not WINDOWSNT */
+
+#ifdef HAVE_WORKING_VFORK
+    /* On many hosts (e.g. Solaris 2.4), if a vforked child calls `signal',
+       this sets the parent's signal handlers as well as the child's.
+       So delay all interrupts whose handlers the child might munge,
+       and record the current handlers so they can be restored later.  */
+    sigemptyset (&blocked);
+    sigaddset (&blocked, SIGPIPE);
+    sigaction (SIGPIPE, 0, &sigpipe_action);
+    sigprocmask (SIG_BLOCK, &blocked, &procmask);
+#endif
+
     BLOCK_INPUT;
 
     pid = vfork ();
@@ -541,11 +558,26 @@
 #else
         setpgrp (pid, pid);
 #endif /* USG */
+
+       /* GTK causes us to ignore SIGPIPE, make sure it is restored
+          in the child.  */
+       signal (SIGPIPE, SIG_DFL);
+#ifdef HAVE_WORKING_VFORK
+       sigprocmask (SIG_SETMASK, &procmask, 0);
+#endif
+
        child_setup (filefd, fd1, fd_error, (char **) new_argv,
                     0, current_dir);
       }
 
     UNBLOCK_INPUT;
+
+#ifdef HAVE_WORKING_VFORK
+    /* Restore the signal state.  */
+    sigaction (SIGPIPE, &sigpipe_action, 0);
+    sigprocmask (SIG_SETMASK, &procmask, 0);
+#endif
+
 #endif /* not WINDOWSNT */
 
     /* The MSDOS case did this already.  */

=== modified file 'src/process.c'
--- a/src/process.c     2011-02-07 05:02:02 +0000
+++ b/src/process.c     2011-02-12 18:53:24 +0000
@@ -1786,6 +1786,7 @@
   sigset_t blocked;
   struct sigaction sigint_action;
   struct sigaction sigquit_action;
+  struct sigaction sigpipe_action;
 #ifdef AIX
   struct sigaction sighup_action;
 #endif
@@ -1898,6 +1899,7 @@
      and record the current handlers so they can be restored later.  */
   sigaddset (&blocked, SIGINT );  sigaction (SIGINT , 0, &sigint_action );
   sigaddset (&blocked, SIGQUIT);  sigaction (SIGQUIT, 0, &sigquit_action);
+  sigaddset (&blocked, SIGPIPE);  sigaction (SIGPIPE, 0, &sigpipe_action);
 #ifdef AIX
   sigaddset (&blocked, SIGHUP );  sigaction (SIGHUP , 0, &sighup_action );
 #endif
@@ -2054,6 +2056,9 @@
 
        signal (SIGINT, SIG_DFL);
        signal (SIGQUIT, SIG_DFL);
+       /* GTK causes us to ignore SIGPIPE, make sure it is restored
+          in the child.  */
+       signal (SIGPIPE, SIG_DFL);
 
        /* Stop blocking signals in the child.  */
        sigprocmask (SIG_SETMASK, &procmask, 0);
@@ -2142,6 +2147,7 @@
   /* Restore the parent's signal handlers.  */
   sigaction (SIGINT, &sigint_action, 0);
   sigaction (SIGQUIT, &sigquit_action, 0);
+  sigaction (SIGPIPE, &sigpipe_action, 0);
 #ifdef AIX
   sigaction (SIGHUP, &sighup_action, 0);
 #endif


reply via email to

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