From: Daniel Kahn Gillmor Date: Wed, 9 Apr 2008 15:59:48 +0000 (-0400) Subject: cleaning up failed pipes properly, flushing error output to ensure it gets printed... X-Git-Tag: monkeysphere_0.1-1~81 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=91ab8af41d77490776ea4e7853fd855f4aad573a;p=monkeysphere.git cleaning up failed pipes properly, flushing error output to ensure it gets printed before we die. --- 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 */