diff options
author | Havoc Pennington <hp@redhat.com> | 2003-10-16 06:34:51 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-10-16 06:34:51 +0000 |
commit | d6e1b2adb3d8e51ce1bb47295cef12d9fe1a15a8 (patch) | |
tree | d94b220a2886b384ddc4f55df4689d79430a6399 /dbus/dbus-sysdeps.c | |
parent | 9b9dd4b80eb2753fc67bed1f48eef89674ba968e (diff) |
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
Diffstat (limited to 'dbus/dbus-sysdeps.c')
-rw-r--r-- | dbus/dbus-sysdeps.c | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 5011f224..8e2a9071 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -76,6 +76,12 @@ void _dbus_abort (void) { +#ifdef DBUS_ENABLE_VERBOSE_MODE + const char *s; + s = _dbus_getenv ("DBUS_PRINT_BACKTRACE"); + if (s && *s) + _dbus_print_backtrace (); +#endif abort (); _exit (1); /* in case someone manages to ignore SIGABRT */ } @@ -3109,7 +3115,11 @@ _dbus_become_daemon (const DBusString *pidfile, { const char *s; pid_t child_pid; + int dev_null_fd; + + _dbus_verbose ("Becoming a daemon...\n"); + _dbus_verbose ("chdir to /\n"); if (chdir ("/") < 0) { dbus_set_error (error, DBUS_ERROR_FAILED, @@ -3117,59 +3127,61 @@ _dbus_become_daemon (const DBusString *pidfile, return FALSE; } + _dbus_verbose ("forking...\n"); switch ((child_pid = fork ())) { case -1: + _dbus_verbose ("fork failed\n"); dbus_set_error (error, _dbus_error_from_errno (errno), "Failed to fork daemon: %s", _dbus_strerror (errno)); return FALSE; break; case 0: + _dbus_verbose ("in child, closing std file descriptors\n"); - - s = _dbus_getenv ("DBUS_DEBUG_DAEMONIZE"); - if (s != NULL) - kill (_dbus_getpid (), SIGSTOP); + /* silently ignore failures here, if someone + * doesn't have /dev/null we may as well try + * to continue anyhow + */ - s = _dbus_getenv ("DBUS_DEBUG_OUTPUT"); - if (s == NULL || *s == '\0') + dev_null_fd = open ("/dev/null", O_RDWR); + if (dev_null_fd >= 0) { - int dev_null_fd; - - /* silently ignore failures here, if someone - * doesn't have /dev/null we may as well try - * to continue anyhow - */ - - dev_null_fd = open ("/dev/null", O_RDWR); - if (dev_null_fd >= 0) - { - dup2 (dev_null_fd, 0); - dup2 (dev_null_fd, 1); - dup2 (dev_null_fd, 2); - } + dup2 (dev_null_fd, 0); + dup2 (dev_null_fd, 1); + + s = _dbus_getenv ("DBUS_DEBUG_OUTPUT"); + if (s == NULL || *s == '\0') + dup2 (dev_null_fd, 2); + else + _dbus_verbose ("keeping stderr open due to DBUS_DEBUG_OUTPUT\n"); } /* Get a predictable umask */ + _dbus_verbose ("setting umask\n"); umask (022); break; default: if (pidfile) { + _dbus_verbose ("parent writing pid file\n"); if (!_dbus_write_pid_file (pidfile, child_pid, error)) { + _dbus_verbose ("pid file write failed, killing child\n"); kill (child_pid, SIGTERM); return FALSE; } } + _dbus_verbose ("parent exiting\n"); _exit (0); break; } + _dbus_verbose ("calling setsid()\n"); if (setsid () == -1) _dbus_assert_not_reached ("setsid() failed"); |