From 91ab8af41d77490776ea4e7853fd855f4aad573a Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Wed, 9 Apr 2008 11:59:48 -0400 Subject: [PATCH] cleaning up failed pipes properly, flushing error output to ensure it gets printed before we die. --- gnutls-helpers.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gnutls-helpers.c b/gnutls-helpers.c index 50b6114..5a567e2 100644 --- a/gnutls-helpers.c +++ b/gnutls-helpers.c @@ -20,6 +20,7 @@ void err(const char* fmt, ...) { va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); + fflush(stderr); } void logfunc(int level, const char* string) { @@ -286,6 +287,10 @@ int create_writing_pipe(pid_t* pid, const char* path, char* const argv[]) { } execv(path, argv); err("exec %s failed (error: %d \"%s\")\n", path, errno, strerror(errno)); + /* close the open file descriptors */ + close(p[0]); + close(0); + exit(1); } else { /* this is the parent */ close(p[0]); /* close unused read end */ -- 2.25.1