Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: I/O to shell function in zsh coproc



Slightly tangential, but I did notice this chunk appears to be wrong.

The value of coprocin and coprocout when they're not in use is -1, not
0, which is of course a valid file descriptor.  So unless there actually
is a coprocess we're always attempting to close file -1.  In my opinion
this isn't very useful.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.187
diff -p -u -r1.187 exec.c
--- Src/exec.c	16 Dec 2010 13:55:36 -0000	1.187
+++ Src/exec.c	15 Feb 2011 18:53:28 -0000
@@ -3218,10 +3218,14 @@ execcmd(Estate state, int input, int out
 			_exit(1);
 		}
 		closem(FDT_INTERNAL);
-		if (coprocin)
+		if (coprocin != -1) {
 		    zclose(coprocin);
-		if (coprocout)
+		    coprocin = -1;
+		}
+		if (coprocout != -1) {
 		    zclose(coprocout);
+		    coprocout = -1;
+		}
 #ifdef HAVE_GETRLIMIT
 		if (!forked)
 		    setlimits(NULL);

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author