aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schwab2011-02-12 19:53:24 +0100
committerAndreas Schwab2011-02-12 19:53:24 +0100
commitc0ad4ea54c2df6ab594c10ec581e30543b8b0df1 (patch)
tree689102bee9424c03fb1c7b01fed4cd21134be7c9
parente2784c87183787f8d5bffb0cf10e08fabe02ff91 (diff)
downloademacs-c0ad4ea54c2df6ab594c10ec581e30543b8b0df1.tar.gz
emacs-c0ad4ea54c2df6ab594c10ec581e30543b8b0df1.zip
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)
-rw-r--r--src/ChangeLog5
-rw-r--r--src/callproc.c32
-rw-r--r--src/process.c6
3 files changed, 43 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 04b0a34d513..8ba7b61290e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12011-02-12 Andreas Schwab <schwab@linux-m68k.org>
2
3 * process.c (create_process): Reset SIGPIPE handler in the child.
4 * callproc.c (Fcall_process): Likewise. (Bug#5238)
5
12011-02-12 Eli Zaretskii <eliz@gnu.org> 62011-02-12 Eli Zaretskii <eliz@gnu.org>
2 7
3 * xdisp.c <this_line_min_pos>: New variable. 8 * xdisp.c <this_line_min_pos>: New variable.
diff --git a/src/callproc.c b/src/callproc.c
index 925eefb4b02..27e8493bcf1 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -445,6 +445,11 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
445 register char **save_environ = environ; 445 register char **save_environ = environ;
446 register int fd1 = fd[1]; 446 register int fd1 = fd[1];
447 int fd_error = fd1; 447 int fd_error = fd1;
448#ifdef HAVE_WORKING_VFORK
449 sigset_t procmask;
450 sigset_t blocked;
451 struct sigaction sigpipe_action;
452#endif
448 453
449#if 0 /* Some systems don't have sigblock. */ 454#if 0 /* Some systems don't have sigblock. */
450 mask = sigblock (sigmask (SIGCHLD)); 455 mask = sigblock (sigmask (SIGCHLD));
@@ -525,6 +530,18 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
525 pid = child_setup (filefd, fd1, fd_error, (char **) new_argv, 530 pid = child_setup (filefd, fd1, fd_error, (char **) new_argv,
526 0, current_dir); 531 0, current_dir);
527#else /* not WINDOWSNT */ 532#else /* not WINDOWSNT */
533
534#ifdef HAVE_WORKING_VFORK
535 /* On many hosts (e.g. Solaris 2.4), if a vforked child calls `signal',
536 this sets the parent's signal handlers as well as the child's.
537 So delay all interrupts whose handlers the child might munge,
538 and record the current handlers so they can be restored later. */
539 sigemptyset (&blocked);
540 sigaddset (&blocked, SIGPIPE);
541 sigaction (SIGPIPE, 0, &sigpipe_action);
542 sigprocmask (SIG_BLOCK, &blocked, &procmask);
543#endif
544
528 BLOCK_INPUT; 545 BLOCK_INPUT;
529 546
530 pid = vfork (); 547 pid = vfork ();
@@ -541,11 +558,26 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
541#else 558#else
542 setpgrp (pid, pid); 559 setpgrp (pid, pid);
543#endif /* USG */ 560#endif /* USG */
561
562 /* GTK causes us to ignore SIGPIPE, make sure it is restored
563 in the child. */
564 signal (SIGPIPE, SIG_DFL);
565#ifdef HAVE_WORKING_VFORK
566 sigprocmask (SIG_SETMASK, &procmask, 0);
567#endif
568
544 child_setup (filefd, fd1, fd_error, (char **) new_argv, 569 child_setup (filefd, fd1, fd_error, (char **) new_argv,
545 0, current_dir); 570 0, current_dir);
546 } 571 }
547 572
548 UNBLOCK_INPUT; 573 UNBLOCK_INPUT;
574
575#ifdef HAVE_WORKING_VFORK
576 /* Restore the signal state. */
577 sigaction (SIGPIPE, &sigpipe_action, 0);
578 sigprocmask (SIG_SETMASK, &procmask, 0);
579#endif
580
549#endif /* not WINDOWSNT */ 581#endif /* not WINDOWSNT */
550 582
551 /* The MSDOS case did this already. */ 583 /* The MSDOS case did this already. */
diff --git a/src/process.c b/src/process.c
index 80e70e49f8e..d026b9d030b 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1786,6 +1786,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1786 sigset_t blocked; 1786 sigset_t blocked;
1787 struct sigaction sigint_action; 1787 struct sigaction sigint_action;
1788 struct sigaction sigquit_action; 1788 struct sigaction sigquit_action;
1789 struct sigaction sigpipe_action;
1789#ifdef AIX 1790#ifdef AIX
1790 struct sigaction sighup_action; 1791 struct sigaction sighup_action;
1791#endif 1792#endif
@@ -1898,6 +1899,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1898 and record the current handlers so they can be restored later. */ 1899 and record the current handlers so they can be restored later. */
1899 sigaddset (&blocked, SIGINT ); sigaction (SIGINT , 0, &sigint_action ); 1900 sigaddset (&blocked, SIGINT ); sigaction (SIGINT , 0, &sigint_action );
1900 sigaddset (&blocked, SIGQUIT); sigaction (SIGQUIT, 0, &sigquit_action); 1901 sigaddset (&blocked, SIGQUIT); sigaction (SIGQUIT, 0, &sigquit_action);
1902 sigaddset (&blocked, SIGPIPE); sigaction (SIGPIPE, 0, &sigpipe_action);
1901#ifdef AIX 1903#ifdef AIX
1902 sigaddset (&blocked, SIGHUP ); sigaction (SIGHUP , 0, &sighup_action ); 1904 sigaddset (&blocked, SIGHUP ); sigaction (SIGHUP , 0, &sighup_action );
1903#endif 1905#endif
@@ -2054,6 +2056,9 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2054 2056
2055 signal (SIGINT, SIG_DFL); 2057 signal (SIGINT, SIG_DFL);
2056 signal (SIGQUIT, SIG_DFL); 2058 signal (SIGQUIT, SIG_DFL);
2059 /* GTK causes us to ignore SIGPIPE, make sure it is restored
2060 in the child. */
2061 signal (SIGPIPE, SIG_DFL);
2057 2062
2058 /* Stop blocking signals in the child. */ 2063 /* Stop blocking signals in the child. */
2059 sigprocmask (SIG_SETMASK, &procmask, 0); 2064 sigprocmask (SIG_SETMASK, &procmask, 0);
@@ -2142,6 +2147,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2142 /* Restore the parent's signal handlers. */ 2147 /* Restore the parent's signal handlers. */
2143 sigaction (SIGINT, &sigint_action, 0); 2148 sigaction (SIGINT, &sigint_action, 0);
2144 sigaction (SIGQUIT, &sigquit_action, 0); 2149 sigaction (SIGQUIT, &sigquit_action, 0);
2150 sigaction (SIGPIPE, &sigpipe_action, 0);
2145#ifdef AIX 2151#ifdef AIX
2146 sigaction (SIGHUP, &sighup_action, 0); 2152 sigaction (SIGHUP, &sighup_action, 0);
2147#endif 2153#endif