summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2008-04-09 11:59:48 -0400
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2008-04-09 11:59:48 -0400
commit91ab8af41d77490776ea4e7853fd855f4aad573a (patch)
treef9a63e7687aa1e8261a559e2ac881c1d69fb8056
parentcdc4ff140d28587c682eaf3d231d4aa47eba1fc8 (diff)
cleaning up failed pipes properly, flushing error output to ensure it gets printed before we die.
-rw-r--r--gnutls-helpers.c5
1 files changed, 5 insertions, 0 deletions
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 */