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

Re: Getting unexpected error from piping "read -d"



On Aug 30,  4:17pm, Bart Schaefer wrote:
}
} #0  gettyinfo (ti=0xbff0a5f0) at ../../zsh-5.0/Src/utils.c:1526
} #1  0x0805c0d9 in bin_read (name=0xb7d58700 "read", args=0xb7d58760, 
}     ops=0xbff0a7d0, func=0) at ../../zsh-5.0/Src/builtin.c:5367
} 
} Looks like SHTTY has become an invalid file descriptor in the child that
} is forked to do the read.  Theoretically it should therefore have been
} set to -1, but that didn't happen.  Looks like workers/27134 is the
} culprit.

The problem with that theory being that there hasn't been an exec() in
the branch where bin_read() runs.

Anyway, the following seems to fix this, and I can't see how it can be
incorrect in any case:


diff --git a/Src/exec.c b/Src/exec.c
index 5ad957f..bf50d0f 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3569,8 +3569,11 @@ closem(int how)
 
     for (i = 10; i <= max_zsh_fd; i++)
 	if (fdtable[i] != FDT_UNUSED &&
-	    (how == FDT_UNUSED || fdtable[i] == how))
+	    (how == FDT_UNUSED || fdtable[i] == how)) {
+	    if (i == SHTTY)
+		SHTTY = -1;
 	    zclose(i);
+	}
 }
 
 /* convert here document into a here string */



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