aboutsummaryrefslogtreecommitdiffstats
path: root/src/callproc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/callproc.c')
-rw-r--r--src/callproc.c32
1 files changed, 32 insertions, 0 deletions
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. */