On Fri, Aug 21, 2009 at 02:18:47PM +0200, Werner Fink wrote:
> On Wed, Aug 19, 2009 at 11:08:33PM +0200, Roland Mainz wrote:
> > 
> > Hi!
> > 
> > ----
> > 
> > The following test should print two "PIPED" lines to stderr when the
> > SIGPIPE signal occurs:
> > -- snip --
> > $ ksh93 -c 'g="false" ; trap "print -u2 PIPED ; \$g && exit 0 ; g=true"
> > PIPE ; while true ; do echo hello ; done' | head
> > -- snip --
> 
> I can redo this if I use a tcsh as interactive shell but not with
> an interactive bash nor interactive ksh.

I'm using now the attachted patch as workaround.


     Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
--- src/cmd/ksh93/sh/fault.c
+++ src/cmd/ksh93/sh/fault.c	2009-08-24 15:52:21.770401660 +0200
@@ -413,6 +413,20 @@ void	sh_chktrap(void)
 			sh.sigflag[sig] &= ~SH_SIGTRAP;
 			if(trap=sh.st.trapcom[sig])
 			{
+				if (sig==SIGPIPE) {
+					int fd;
+					sh.lastsig=SIGPIPE;
+					for(fd = 0; fd < sh.lim.open_max; fd++)
+					{
+						if (sh.fdstatus[fd] == IOCLOSE)
+							continue;
+						if ((sh.fdstatus[fd]&IOWRITE) == 0)
+							continue;
+						if (sferror(sh.sftable[fd]) == 0)
+							continue;
+						sh_close(fd);
+					}
+				}
 				sh.oldexit = SH_EXITSIG|sig;
 				sh_trap(trap,0);
 			}
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to