From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4940 invoked from network); 11 Jul 2000 16:59:57 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 11 Jul 2000 16:59:57 -0000 Received: (qmail 18973 invoked by alias); 11 Jul 2000 16:59:49 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12222 Received: (qmail 18966 invoked from network); 11 Jul 2000 16:59:48 -0000 Date: Tue, 11 Jul 2000 17:59:21 +0100 From: Peter Stephenson Subject: PATCH: Re: Multi-redirection bug In-reply-to: "Your message of Tue, 11 Jul 2000 15:52:01 +0200." <20000711155201.A17330@vin.ens-lyon.fr> To: zsh-workers@sunsite.auc.dk (Zsh hackers list), Vincent Lefevre Message-id: <0FXJ00MQFLUXDK@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT > 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 "", 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 Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070