After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 732019 - gtestdbus: Don’t close stdout for dbus-daemon
gtestdbus: Don’t close stdout for dbus-daemon
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.41.x
Other All
: Normal major
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-06-21 22:02 UTC by Philip Withnall
Modified: 2014-06-22 12:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtestdbus: Don’t close stdout for dbus-daemon (2.72 KB, patch)
2014-06-21 22:03 UTC, Philip Withnall
reviewed Details | Review
gtestdbus: Don’t close stdout for dbus-daemon (2.81 KB, patch)
2014-06-22 12:02 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2014-06-21 22:02:40 UTC
Patch attached. See the commit message for rationale.
Comment 1 Philip Withnall 2014-06-21 22:03:00 UTC
Created attachment 278908 [details] [review]
gtestdbus: Don’t close stdout for dbus-daemon

The stdout FD passed to dbus-daemon is propagated to all its child
processes, such as service activated processes. If we close the FD after
reading the bus address from the daemon, any child process which
subsequently writes to stdout (e.g. for logging) will get a SIGPIPE and
explode.

Instead of closing the stdout FD immediately after dbus-daemon has
spawned, keep it open until the daemon is killed.
Comment 2 Colin Walters 2014-06-22 11:26:49 UTC
Review of attachment 278908 [details] [review]:

::: gio/gtestdbus.c
@@ +619,3 @@
+   * and if we close it, they will get a SIGPIPE and die when they try to write
+   * to their stdout. */
+  channel = g_io_channel_unix_new (dup (self->priv->bus_stdout_fd));

Any reason not to check for an error from dup() ?
Comment 3 Philip Withnall 2014-06-22 12:02:43 UTC
Created attachment 278923 [details] [review]
gtestdbus: Don’t close stdout for dbus-daemon

The stdout FD passed to dbus-daemon is propagated to all its child
processes, such as service activated processes. If we close the FD after
reading the bus address from the daemon, any child process which
subsequently writes to stdout (e.g. for logging) will get a SIGPIPE and
explode.

Instead of closing the stdout FD immediately after dbus-daemon has
spawned, keep it open until the daemon is killed.
Comment 4 Philip Withnall 2014-06-22 12:03:23 UTC
Comment on attachment 278908 [details] [review]
gtestdbus: Don’t close stdout for dbus-daemon

Added a g_assert_cmpint(), since the rest of the error handling in the file uses assertions rather than error messages.
Comment 5 Colin Walters 2014-06-22 12:06:10 UTC
Review of attachment 278923 [details] [review]:

LGTM, thanks!
Comment 6 Philip Withnall 2014-06-22 12:52:35 UTC
Comment on attachment 278923 [details] [review]
gtestdbus: Don’t close stdout for dbus-daemon

commit d80adeaa960ddfa13837900d0391f9bd9c239f78
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Sat Jun 21 23:01:08 2014 +0100

    gtestdbus: Don’t close stdout for dbus-daemon
    
    The stdout FD passed to dbus-daemon is propagated to all its child
    processes, such as service activated processes. If we close the FD after
    reading the bus address from the daemon, any child process which
    subsequently writes to stdout (e.g. for logging) will get a SIGPIPE and
    explode.
    
    Instead of closing the stdout FD immediately after dbus-daemon has
    spawned, keep it open until the daemon is killed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732019

 gio/gtestdbus.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)