summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-02-22 11:35:13 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-02-22 11:35:13 +0000
commit48315b019b12ad62ee2e260926db2d0167f45450 (patch)
tree65e589fdfacd445aefbde1e2a66169dbd51c0563 /Src
parent7977ce07470558dbc26b3bc97548aa6e263f4d4c (diff)
downloadzsh-48315b019b12ad62ee2e260926db2d0167f45450.tar.gz
zsh-48315b019b12ad62ee2e260926db2d0167f45450.tar.xz
zsh-48315b019b12ad62ee2e260926db2d0167f45450.zip
unposted: add debug code to zclose()
Diffstat (limited to 'Src')
-rw-r--r--Src/utils.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Src/utils.c b/Src/utils.c
index 0168c8287..f488d9de6 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1,3 +1,4 @@
+
 /*
  * utils.c - miscellaneous utilities
  *
@@ -1704,6 +1705,14 @@ mod_export int
 zclose(int fd)
 {
     if (fd >= 0) {
+	/*
+	 * We sometimes zclose() an fd twice where the second
+	 * time is a catch-all in case there was a failure using
+	 * the fd.  This is harmless but we need to trap it
+	 * for the error check here.
+	 */
+	DPUTS2(fd > max_zsh_fd && fdtable[fd] != FDT_UNUSED,
+	       "BUG: fd is %d, max_zsh_fd is %d", fd, max_zsh_fd);
 	fdtable[fd] = FDT_UNUSED;
 	while (max_zsh_fd > 0 && fdtable[max_zsh_fd] == FDT_UNUSED)
 	    max_zsh_fd--;