zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@cambridgesiliconradio.com>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list),
	Vincent Lefevre <vincent@vinc17.org>
Subject: PATCH: Re: Multi-redirection bug
Date: Tue, 11 Jul 2000 17:59:21 +0100	[thread overview]
Message-ID: <0FXJ00MQFLUXDK@la-la.cambridgesiliconradio.com> (raw)
In-Reply-To: "Your message of Tue, 11 Jul 2000 15:52:01 +0200." <20000711155201.A17330@vin.ens-lyon.fr>

> 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@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


       reply	other threads:[~2000-07-11 16:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20000711155201.A17330@vin.ens-lyon.fr>
2000-07-11 16:59 ` Peter Stephenson [this message]
2000-07-11 17:18   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0FXJ00MQFLUXDK@la-la.cambridgesiliconradio.com \
    --to=pws@cambridgesiliconradio.com \
    --cc=vincent@vinc17.org \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).