summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-spawn.c25
-rw-r--r--dbus/dbus-spawn.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c
index 15e3dec3..125aea7c 100644
--- a/dbus/dbus-spawn.c
+++ b/dbus/dbus-spawn.c
@@ -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));
@@ -623,6 +624,30 @@ _dbus_babysitter_get_child_exited (DBusBabysitter *sitter)
}
/**
+ * 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
* the child process has not exited, does nothing (error
diff --git a/dbus/dbus-spawn.h b/dbus/dbus-spawn.h
index 0eed6bab..7d8a67a7 100644
--- a/dbus/dbus-spawn.h
+++ b/dbus/dbus-spawn.h
@@ -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,