From dc38967fd35286f9489a8cdcb3d811d34113ceca Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 29 Aug 2011 15:18:29 -0400 Subject: [PATCH] Don't call close on invalid fds If an fd is -1, don't call close() on it, since that leads to EBDAF and complaints from valgrind. https://bugzilla.gnome.org/show_bug.cgi?id=657593 --- glib/gtestutils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/glib/gtestutils.c b/glib/gtestutils.c index 623ee12..00bad2b 100644 --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@ -1817,9 +1817,12 @@ g_test_trap_fork (guint64 usec_timeout, } } } - close (stdout_pipe[0]); - close (stderr_pipe[0]); - close (stdtst_pipe[0]); + if (stdout_pipe[0] != -1) + close (stdout_pipe[0]); + if (stderr_pipe[0] != -1) + close (stderr_pipe[0]); + if (stdtst_pipe[0] != -1) + close (stdtst_pipe[0]); if (need_wait) { int status = 0; -- 2.7.4