[glib] gtestutils: Error out if /dev/null stdin redirection fails
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gtestutils: Error out if /dev/null stdin redirection fails
- Date: Mon, 26 May 2014 07:40:21 +0000 (UTC)
commit d3fd88ddd54dd533b09e8782a8ffc0dc9f6f0571
Author: Philip Withnall <philip withnall collabora co uk>
Date: Fri May 16 23:08:10 2014 +0100
gtestutils: Error out if /dev/null stdin redirection fails
https://bugzilla.gnome.org/show_bug.cgi?id=730189
glib/gtestutils.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 88a6fc0..e67078d 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -2680,7 +2680,11 @@ g_test_trap_fork (guint64 usec_timeout,
close (stdout_pipe[0]);
close (stderr_pipe[0]);
if (!(test_trap_flags & G_TEST_TRAP_INHERIT_STDIN))
- fd0 = g_open ("/dev/null", O_RDONLY, 0);
+ {
+ fd0 = g_open ("/dev/null", O_RDONLY, 0);
+ if (fd0 < 0)
+ g_error ("failed to open /dev/null for stdin redirection");
+ }
if (sane_dup2 (stdout_pipe[1], 1) < 0 || sane_dup2 (stderr_pipe[1], 2) < 0 || (fd0 >= 0 && sane_dup2
(fd0, 0) < 0))
g_error ("failed to dup2() in forked test program: %s", g_strerror (errno));
if (fd0 >= 3)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]