[Pcsclite-muscle] [PATCH 1/1] pcscdaemon: fix "at_exit() write() failed: Bad file descriptor"

Herve Codina Herve.CODINA
Wed Aug 5 08:03:59 PDT 2015


In case of receiving a signal to terminate after init has been completed,
at_exit() is called and tries to write to a closed pipe.

This patch simply set pipe to -1 in order to invalidate it after closing.
Pipe value checks are allready present in the code.

Signed-off-by: Herve Codina <Herve.CODINA at celad.com>
---
 src/pcscdaemon.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/pcscdaemon.c b/src/pcscdaemon.c
index 27ee6c9..78b65b8 100644
--- a/src/pcscdaemon.c
+++ b/src/pcscdaemon.c
@@ -681,6 +681,7 @@ int main(int argc, char **argv)
 			Log2(PCSC_LOG_ERROR, "write() failed: %s", strerror(errno));
 		}
 		close(pipefd[1]);
+		pipefd[1] = -1;
 	}
 
 	SVCServiceRunLoop();
@@ -708,6 +709,7 @@ static void at_exit(void)
 			Log2(PCSC_LOG_ERROR, "write() failed: %s", strerror(errno));
 		}
 		close(pipefd[1]);
+		pipefd[1] = -1;
 	}
 
 	exit(ExitValue);
-- 
1.7.9.5





More information about the pcsclite-muscle mailing list