ksh/ksh93-sigpipe.dif

31 lines
803 B
Plaintext

--- src/cmd/ksh93/sh/fault.c
+++ src/cmd/ksh93/sh/fault.c 2010-06-28 14:04:13.858925163 +0000
@@ -418,8 +418,25 @@ void sh_chktrap(void)
if(trap=sh.st.trapcom[sig])
{
Sfio_t *fp;
- if(sig==SIGPIPE && (fp=sfpool((Sfio_t*)0,sh.outpool,SF_WRITE)) && sferror(fp))
- sfclose(fp);
+ if(sig==SIGPIPE) {
+ sh.lastsig=SIGPIPE;
+#if 0
+ if ((fp=sfpool((Sfio_t*)0,sh.outpool,SF_WRITE)) && sferror(fp))
+ sfclose(fp);
+#else
+ int fd;
+ 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);
+ }
+#endif
+ }
sh.oldexit = SH_EXITSIG|sig;
sh_trap(trap,0);
}