Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

SIGPIPE handling



Since it seems that noone know why SIGPIPE is trapped for shells under job
control, let's try to remove this.  This change only affects interactive
shells since when MONITOR is not set SIGPIPE is not handled specially.  And
since SIGPIPE is not related to process groups and not used for job
control, it should not be a special case.  Probably it was just an
oversight when some developer thought that SIGPIPE is in the same category
as SIGT{OU,IN,STP} signals.  SIGPIPE is still not reported after this
patch.  In bash, cat builtin.c | : reports `Broken pipe' while zsh and ksh
and pdksh remains silent, which is better I think.

This patch should be applied to zsh-3.0 as well.  The jobs.c hunk will be
rejected.  Just apply this rejected patch to builtin.c using

patch builtin.c jobs.c.rej

Alternatively you can edit the patch and replace jobs.c with builtin.c.

Zoltan


*** Src/signals.c	1997/05/18 09:04:56	3.1.2.5
--- Src/signals.c	1997/05/18 18:38:40
***************
*** 590,597 ****
  {
      if (sig == -1)
          return 1;
!     if (jobbing && (sig == SIGTTOU || sig == SIGTSTP ||
! 		    sig == SIGTTIN || sig == SIGPIPE)) {
          zerr("can't trap SIG%s in interactive shells", sigs[sig], 0);
          return 1;
      }
--- 590,596 ----
  {
      if (sig == -1)
          return 1;
!     if (jobbing && (sig == SIGTTOU || sig == SIGTSTP || sig == SIGTTIN)) {
          zerr("can't trap SIG%s in interactive shells", sigs[sig], 0);
          return 1;
      }
***************
*** 625,632 ****
      int trapped;
  
      if (sig == -1 || !(trapped = sigtrapped[sig]) ||
! 	(jobbing && (sig == SIGTTOU || sig == SIGTSTP ||
! 		     sig == SIGTTIN || sig == SIGPIPE))) {
          return;
      }
      sigtrapped[sig] = 0;
--- 624,630 ----
      int trapped;
  
      if (sig == -1 || !(trapped = sigtrapped[sig]) ||
! 	(jobbing && (sig == SIGTTOU || sig == SIGTSTP || sig == SIGTTIN))) {
          return;
      }
      sigtrapped[sig] = 0;
*** Src/jobs.c	1997/05/18 09:09:03	3.1.2.4
--- Src/jobs.c	1997/05/18 18:36:33
***************
*** 1270,1276 ****
      }
      if (jobbing) {
  	/* stop ignoring signals */
- 	signal_default(SIGPIPE);
  	signal_default(SIGTTIN);
  	signal_default(SIGTSTP);
  	signal_default(SIGTTOU);
--- 1270,1275 ----
***************
*** 1288,1294 ****
  	signal_ignore(SIGTTOU);
  	signal_ignore(SIGTSTP);
  	signal_ignore(SIGTTIN);
- 	signal_ignore(SIGPIPE);
      }
      return 0;
  }
--- 1287,1292 ----
*** Src/init.c	1997/05/18 09:09:03	3.1.2.11
--- Src/init.c	1997/05/18 18:38:57
***************
*** 588,594 ****
  	    signal_ignore(SIGTTOU);
  	    signal_ignore(SIGTSTP);
  	    signal_ignore(SIGTTIN);
- 	    signal_ignore(SIGPIPE);
  	    attachtty(mypgrp);
  	}
      }
--- 588,593 ----
*** Src/exec.c	1997/05/18 09:04:56	3.1.2.9
--- Src/exec.c	1997/05/18 18:39:06
***************
*** 1936,1942 ****
  	signal_default(SIGTTOU);
  	signal_default(SIGTTIN);
  	signal_default(SIGTSTP);
- 	signal_default(SIGPIPE);
      }
      if (interact) {
  	signal_default(SIGTERM);
--- 1936,1941 ----



Messages sorted by: Reverse Date, Date, Thread, Author