[PATCH 58/65] set fd to -1 on close

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun, 5 Jul 2015 22:51:33 +0200

---
 ii.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/ii.c b/ii.c
index e2541cf..9266a77 100644
--- a/ii.c
+++ b/ii.c
_AT_@ -209,15 +209,22 @@ channel_open(Channel *c)
 
 	return 0;
 err:
-	if(c->fdin > 2)
+	if(c->fdin > 2) {
 		close(c->fdin);
+		c->fdin = -1;
+	}
+
 	return -1;
 }
 
 static int
 channel_reopen(Channel *c)
 {
-	close(c->fdin);
+	if (c->fdin > 2) {
+		close(c->fdin);
+		c->fdin = -1;
+	}
+
 	return channel_open(c);
 }
 
_AT_@ -305,7 +312,10 @@ channel_rm(Channel *c)
 static void
 channel_leave(Channel *c)
 {
-	close(c->fdin);
+	if(c->fdin > 2) {
+		close(c->fdin);
+		c->fdin = -1;
+	}
 	/* remove "in" file on leaving the channel */
 	unlink(c->inpath);
 	channel_rm(c);
-- 
2.4.10
--Multipart=_Mon__9_May_2016_17_21_10_+0200_I.6cpFVydhq75aaE
Content-Type: text/x-diff;
 name="0059-bump-version-to-1.8-but-dont-show-it-in-usage-anymor.patch"
Content-Disposition: attachment;
 filename="0059-bump-version-to-1.8-but-dont-show-it-in-usage-anymor.patch"
Content-Transfer-Encoding: 7bit
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Mon May 09 2016 - 17:24:22 CEST