summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-01 03:44:09 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-01 03:44:09 +0200
commit5e374895934d6b8960e391a2b3a1fe57e153a7f8 (patch)
tree108c0b03e900ae04748e5ae9b363a46afe35f9ed /src
parent6ec1117a7416a999d588abf68a599b8bfd965ccd (diff)
systemctl: return error codes for failed jobs
Diffstat (limited to 'src')
-rw-r--r--src/systemctl.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/systemctl.c b/src/systemctl.c
index cf2871dda1..d6f4709c42 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -530,13 +530,18 @@ finish:
return r;
}
+typedef struct WaitData {
+ Set *set;
+ bool failed;
+} WaitData;
+
static DBusHandlerResult wait_filter(DBusConnection *connection, DBusMessage *message, void *data) {
DBusError error;
- Set *s = data;
+ WaitData *d = data;
assert(connection);
assert(message);
- assert(s);
+ assert(d);
dbus_error_init(&error);
@@ -552,17 +557,22 @@ static DBusHandlerResult wait_filter(DBusConnection *connection, DBusMessage *me
} else if (dbus_message_is_signal(message, "org.freedesktop.systemd1.Manager", "JobRemoved")) {
uint32_t id;
const char *path;
+ dbus_bool_t success = true;
if (!dbus_message_get_args(message, &error,
DBUS_TYPE_UINT32, &id,
DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_BOOLEAN, &success,
DBUS_TYPE_INVALID))
log_error("Failed to parse message: %s", error.message);
else {
char *p;
- if ((p = set_remove(s, (char*) path)))
+ if ((p = set_remove(d->set, (char*) path)))
free(p);
+
+ if (!success)
+ d->failed = true;
}
}
@@ -627,11 +637,16 @@ finish:
static int wait_for_jobs(DBusConnection *bus, Set *s) {
int r;
+ WaitData d;
assert(bus);
assert(s);
- if (!dbus_connection_add_filter(bus, wait_filter, s, NULL)) {
+ zero(d);
+ d.set = s;
+ d.failed = false;
+
+ if (!dbus_connection_add_filter(bus, wait_filter, &d, NULL)) {
log_error("Failed to add filter.");
r = -ENOMEM;
goto finish;
@@ -641,7 +656,10 @@ static int wait_for_jobs(DBusConnection *bus, Set *s) {
dbus_connection_read_write_dispatch(bus, -1))
;
- r = 0;
+ if (!arg_quiet && d.failed)
+ log_error("Job failed, see logs for details.");
+
+ r = d.failed ? -EIO : 0;
finish:
/* This is slightly dirty, since we don't undo the filter registration. */