]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
2007-07-24 Richard Hughes <richard@hughsie.com>
authorRichard Hughes <richard@hughsie.com>
Tue, 24 Jul 2007 11:37:20 +0000 (11:37 +0000)
committerRichard Hughes <richard@hughsie.com>
Tue, 24 Jul 2007 11:37:20 +0000 (11:37 +0000)
* dbus/dbus-spawn.c: (read_data),
(_dbus_babysitter_get_child_exit_status):
* dbus/dbus-spawn.h:
Add a function so we can get access to the exit status of the launch
helper.
By providing the return code and not the error we can leave the
'what does this mean?' to the bus launch code and not include it in the
dbus directory.

ChangeLog
dbus/dbus-spawn.c
dbus/dbus-spawn.h

index 9f0d9bbbcdac426ffdeaed0bccb41218a09ffc4f..8c9a48b9d562756f659ab8a9da1fddd372f33659 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-07-24  Richard Hughes  <richard@hughsie.com>
+
+       * dbus/dbus-spawn.c: (read_data),
+       (_dbus_babysitter_get_child_exit_status):
+       * dbus/dbus-spawn.h:
+       Add a function so we can get access to the exit status of the launch
+       helper.
+       By providing the return code and not the error we can leave the
+       'what does this mean?' to the bus launch code and not include it in the
+       dbus directory.
+
 2007-07-24  Richard Hughes  <richard@hughsie.com>
 
        * bus/activation-exit-codes.h:
index 15e3dec368e9c49405b9303171acee751776fd55..125aea7c3b3357f153244f13c2cf85508ca5caa6 100644 (file)
@@ -417,6 +417,7 @@ read_data (DBusBabysitter *sitter,
                   {
                     sitter->have_child_status = TRUE;
                     sitter->status = arg;
+                    sitter->errnum = WEXITSTATUS (sitter->status);
                     _dbus_verbose ("recorded child status exited = %d signaled = %d exitstatus = %d termsig = %d\n",
                                    WIFEXITED (sitter->status), WIFSIGNALED (sitter->status),
                                    WEXITSTATUS (sitter->status), WTERMSIG (sitter->status));
@@ -622,6 +623,30 @@ _dbus_babysitter_get_child_exited (DBusBabysitter *sitter)
   return sitter->socket_to_babysitter < 0;
 }
 
+/**
+ * Gets the exit status of the child. We do this so implimentation specific
+ * detail is not cluttering up dbus, for example the system laucher code.
+ *
+ * @param sitter the babysitter
+ * @param status the returned status code
+ * @returns #FALSE on failure
+ */
+dbus_bool_t
+_dbus_babysitter_get_child_exit_status (DBusBabysitter *sitter, int *status)
+{
+  if (!_dbus_babysitter_get_child_exited (sitter))
+    _dbus_assert_not_reached ("Child has not exited");
+
+  if (sitter->errnum != WEXITSTATUS (sitter->status))
+    _dbus_assert_not_reached ("Status is not exit!");
+
+  if (!sitter->have_child_status)
+    _dbus_assert_not_reached ("Not a child!");
+
+  *status = sitter->status;
+  return TRUE;
+}
+
 /**
  * Sets the #DBusError with an explanation of why the spawned
  * child process exited (on a signal, or whatever). If
index 0eed6bab9baf0b8a20326c2f8bffe7420059f473..7d8a67a71255cf7373ddec7de11f7af50efdb2da 100644 (file)
@@ -47,6 +47,8 @@ void        _dbus_babysitter_kill_child           (DBusBabysitter            *si
 dbus_bool_t _dbus_babysitter_get_child_exited     (DBusBabysitter            *sitter);
 void        _dbus_babysitter_set_child_exit_error (DBusBabysitter            *sitter,
                                                    DBusError                 *error);
+dbus_bool_t _dbus_babysitter_get_child_exit_status (DBusBabysitter           *sitter,
+                                                    int                      *status);
 dbus_bool_t _dbus_babysitter_set_watch_functions  (DBusBabysitter            *sitter,
                                                    DBusAddWatchFunction       add_function,
                                                    DBusRemoveWatchFunction    remove_function,