summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-07-17 01:53:42 +0000
committerHavoc Pennington <hp@redhat.com>2003-07-17 01:53:42 +0000
commit2ad05d5ce45b05b399bcdfc5c04c95b1627c90f3 (patch)
tree04df8e311a1851b8881c85e894d578992024e9fc
parent1ec66944499112b1d5c0b6d73598427c1221eaf8 (diff)
2003-07-16 Havoc Pennington <hp@pobox.com>
* tools/dbus-launch.c (babysit): close stdout/stderr in the babysitter process, as suggested by Thomas Leonard, so an "eval `dbus-launch --exit-with-session`" will actually return
-rw-r--r--ChangeLog7
-rw-r--r--tools/dbus-launch.c23
2 files changed, 27 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 1876cfba..d405daed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2003-07-16 Havoc Pennington <hp@pobox.com>
+ * tools/dbus-launch.c (babysit): close stdout/stderr in the
+ babysitter process, as suggested by Thomas Leonard, so
+ an "eval `dbus-launch --exit-with-session`" will actually
+ return
+
+2003-07-16 Havoc Pennington <hp@pobox.com>
+
* configure.in: print out EXPANDED_* variables in the summary at
the end; clean up the code that computes EXPANDED_ variables and
get the ones using exec_prefix right. Should make things work
diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c
index 4d21d105..3b429013 100644
--- a/tools/dbus-launch.c
+++ b/tools/dbus-launch.c
@@ -460,10 +460,11 @@ babysit (int exit_with_session,
char buf[MAX_PID_LEN];
long val;
char *end;
+ int dev_null_fd;
/* We chdir ("/") since we are persistent and daemon-like, and fork
* again so dbus-launch can reap the parent. However, we don't
- * setsid() or close fd 0,1,2 because the idea is to remain attached
+ * setsid() or close fd 0 because the idea is to remain attached
* to the tty and the X server in order to kill the message bus
* when the session ends.
*/
@@ -473,8 +474,24 @@ babysit (int exit_with_session,
fprintf (stderr, "Could not change to root directory: %s\n",
strerror (errno));
exit (1);
- }
+ }
+ /* Move stdout/stderr so we don't block an "eval" or otherwise
+ * lock up.
+ */
+ dev_null_fd = open ("/dev/null", O_RDWR);
+ if (dev_null_fd >= 0)
+ {
+ dup2 (dev_null_fd, 1);
+ dup2 (dev_null_fd, 2);
+ }
+ else
+ {
+ fprintf (stderr, "Failed to open /dev/null: %s\n",
+ strerror (errno));
+ /* continue, why not */
+ }
+
ret = fork ();
if (ret < 0)
@@ -541,7 +558,7 @@ babysit (int exit_with_session,
/* Write data to launcher */
write_pid (write_bus_pid_fd, bus_pid_to_kill);
close (write_bus_pid_fd);
-
+
if (exit_with_session)
{
/* Bus is now started and launcher has needed info;