Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: Multi-redirection bug
- X-seq: zsh-workers 12222
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list), Vincent Lefevre <vincent@xxxxxxxxxx>
- Subject: PATCH: Re: Multi-redirection bug
- Date: Tue, 11 Jul 2000 17:59:21 +0100
- In-reply-to: "Your message of Tue, 11 Jul 2000 15:52:01 +0200." <20000711155201.A17330@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
> Last year, I sent a mail to this mailing-list about a probable bug
> concerning zsh MULTIOS redirections. But there were no replies.
> Then, I thought it was solved... until now.
>
> To be more clear, I take a simple (but useless) example. If I type
> the following command under zsh
>
> cat /dev/zero >/dev/null 2>|f1 2>|f2
>
> I get two processes: "cat /dev/zero" and a child "zsh". But when
> I resize the terminal, the child dies (it becomes "<defunct>", as
> "cat /dev/zero" doesn't wait for it). And this prevents f1 or f2
> (or maybe both) from getting the data.
I find it hard to see anything with this variant, since stderr is empty
anyway. But the basic problem seems to be real enough. See if this fixes
it. It fixes what I was seeing, but unfortunately that was rather worse:
the parent process got a SIGPIPE when the child exited, and that caused it
to crash. The SIGPIPE is inevitable, but the shell usually doesn't exit on
it, so there may be something else wrong.
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.11
diff -u -r1.11 exec.c
--- Src/exec.c 2000/07/11 16:43:26 1.11
+++ Src/exec.c 2000/07/11 16:56:25
@@ -1356,14 +1356,28 @@
closeallelse(mn);
if (mn->rflag) {
/* tee process */
- while ((len = read(mn->pipe, buf, TCBUFSIZE)) > 0)
+ while ((len = read(mn->pipe, buf, TCBUFSIZE)) != 0) {
+ if (len < 0) {
+ if (errno == EINTR)
+ continue;
+ else
+ break;
+ }
for (i = 0; i < mn->ct; i++)
write(mn->fds[i], buf, len);
+ }
} else {
/* cat process */
for (i = 0; i < mn->ct; i++)
- while ((len = read(mn->fds[i], buf, TCBUFSIZE)) > 0)
+ while ((len = read(mn->fds[i], buf, TCBUFSIZE)) != 0) {
+ if (len < 0) {
+ if (errno == EINTR)
+ continue;
+ else
+ break;
+ }
write(mn->pipe, buf, len);
+ }
}
_exit(0);
}
--
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author