zsh-workers
 help / color / mirror / code / Atom feed
* exec fd>>(list) freezes
@ 2004-10-28 17:33 Clint Adams
  2004-10-28 17:50 ` Clint Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Clint Adams @ 2004-10-28 17:33 UTC (permalink / raw)
  To: zsh-workers

In the past, "exec 8>>(grep a)" used to work; now it doesn't return.  Is
this broken or am I confused?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: exec fd>>(list) freezes
  2004-10-28 17:33 exec fd>>(list) freezes Clint Adams
@ 2004-10-28 17:50 ` Clint Adams
  2004-10-28 17:56   ` Clint Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Clint Adams @ 2004-10-28 17:50 UTC (permalink / raw)
  To: zsh-workers

> In the past, "exec 8>>(grep a)" used to work; now it doesn't return.  Is
> this broken or am I confused?

Specifically, it worked in 4.0.9 and prior versions, but chokes on 4.1.1
and later.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: exec fd>>(list) freezes
  2004-10-28 17:50 ` Clint Adams
@ 2004-10-28 17:56   ` Clint Adams
  2004-10-29  2:00     ` Geoff Wing
  2004-10-29 10:06     ` Peter Stephenson
  0 siblings, 2 replies; 5+ messages in thread
From: Clint Adams @ 2004-10-28 17:56 UTC (permalink / raw)
  To: zsh-workers

> Specifically, it worked in 4.0.9 and prior versions, but chokes on 4.1.1
> and later.

Is this because of 18492?  Did the 4.0 series changelogs get lost?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: exec fd>>(list) freezes
  2004-10-28 17:56   ` Clint Adams
@ 2004-10-29  2:00     ` Geoff Wing
  2004-10-29 10:06     ` Peter Stephenson
  1 sibling, 0 replies; 5+ messages in thread
From: Geoff Wing @ 2004-10-29  2:00 UTC (permalink / raw)
  To: Zsh Hackers

Clint Adams <clint@zsh.org> output:
:> Specifically, it worked in 4.0.9 and prior versions, but chokes on 4.1.1
:> and later.
:Is this because of 18492?  Did the 4.0 series changelogs get lost?

Reminder: 4.0 was a stable series and patches were applied to the branch
tag  zsh-4_0-patches
Thus you would want to check the ChangeLog in the main directory with
that tag.

Regards,
-- 
Geoff Wing


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: exec fd>>(list) freezes
  2004-10-28 17:56   ` Clint Adams
  2004-10-29  2:00     ` Geoff Wing
@ 2004-10-29 10:06     ` Peter Stephenson
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2004-10-29 10:06 UTC (permalink / raw)
  To: zsh-workers

Clint Adams wrote:
> In the past, "exec 8>>(grep a)" used to work; now it doesn't return.  Is
> this broken or am I confused?
...
> > Specifically, it worked in 4.0.9 and prior versions, but chokes on 4.1.1
> > and later.
> 
> Is this because of 18492?

Yes, it's now waiting for the grep process to finish.  This is
obviously inappropriate if the fd is being opened for the shell's
own future use.

A test for this might be sensible, but in this case the race which was
fixed by 18492 is intrinsic.  You don't even have a PID to wait for.
(If you had wanted one, you would have used a coprocess.)

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.76
diff -u -r1.76 exec.c
--- Src/exec.c	21 Oct 2004 00:33:50 -0000	1.76
+++ Src/exec.c	29 Oct 2004 10:01:39 -0000
@@ -2205,7 +2205,7 @@
 
     /* Do process substitutions */
     if (redir)
-	spawnpipes(redir);
+	spawnpipes(redir, nullexec);
 
     /* Do io redirections */
     while (redir && nonempty(redir)) {
@@ -3113,11 +3113,17 @@
 #endif   /* HAVE_FIFOS and PATH_DEV_FD not defined */
 }
 
-/* > >(...) or < <(...) (does not use named pipes) */
+/*
+ * > >(...) or < <(...) (does not use named pipes)
+ *
+ * If the second argument is 1, this is part of
+ * an "exec < <(...)" or "exec > >(...)" and we shouldn't
+ * wait for the job to finish before continuing.
+ */
 
 /**/
 static int
-getpipe(char *cmd)
+getpipe(char *cmd, int nullexec)
 {
     Eprog prog;
     int pipes[2], out = *cmd == Inang;
@@ -3133,7 +3139,8 @@
 	    zclose(pipes[!out]);
 	    return -1;
 	}
-	addproc(pid, NULL, 1, &bgtime);
+	if (!nullexec)
+	    addproc(pid, NULL, 1, &bgtime);
 	return pipes[!out];
     }
     entersubsh(Z_ASYNC, 1, 0, 0);
@@ -3157,11 +3164,17 @@
     pp[1] = movefd(pp[1]);
 }
 
-/* Do process substitution with redirection */
+/*
+ * Do process substitution with redirection
+ *
+ * If the second argument is 1, this is part of
+ * an "exec < <(...)" or "exec > >(...)" and we shouldn't
+ * wait for the job to finish before continuing.
+ */
 
 /**/
 static void
-spawnpipes(LinkList l)
+spawnpipes(LinkList l, int nullexec)
 {
     LinkNode n;
     Redir f;
@@ -3172,7 +3185,7 @@
 	f = (Redir) getdata(n);
 	if (f->type == REDIR_OUTPIPE || f->type == REDIR_INPIPE) {
 	    str = f->name;
-	    f->fd2 = getpipe(str);
+	    f->fd2 = getpipe(str, nullexec);
 	}
     }
 }

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-10-29 10:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-28 17:33 exec fd>>(list) freezes Clint Adams
2004-10-28 17:50 ` Clint Adams
2004-10-28 17:56   ` Clint Adams
2004-10-29  2:00     ` Geoff Wing
2004-10-29 10:06     ` Peter Stephenson

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).