From 32d4d99472cd94516804be8d086a9d4b9d04aaf5 Mon Sep 17 00:00:00 2001 From: Christopher Wellons Date: Mon, 18 May 2020 19:09:22 -0400 Subject: [PATCH] Properly terminate pinentry protocol (BYE) This isn't strictly necessary on unix-like systems since it will exit when the pipes are closed. Unfortunately Windows isn't so nice and neat and the program will remain open indefinitely even though its inputs and outputs have been closed. So ask pinentry to terminate gracefully. --- src/enchive.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/enchive.c b/src/enchive.c index a52582c..5d2e834 100644 --- a/src/enchive.c +++ b/src/enchive.c @@ -495,6 +495,9 @@ pinentry(FILE *pfi, FILE *pfo, char *buf, size_t len, char *prompt) pinentry_decode(buf, len, line + 2); else fatal("pinentry protocol failure"); + + if (fprintf(pfi, "BYE\n") < 0 || fflush(pfi) < 0) + fatal("pinentry write() -- %s", strerror(errno)); } #if defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__)