diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-08-13 02:07:22 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-08-13 02:07:22 +0200 |
commit | 598b557bf0dea33db2c13d383382efbd847ed5f0 (patch) | |
tree | 6a41cbfd10fa91ca4a2afd948a0c89832637481e /src/systemctl.c | |
parent | 20c5e441cb22b94a4850b7384e490a80a82ee530 (diff) |
systemctl: when calling 'status' accept a PID
Diffstat (limited to 'src/systemctl.c')
-rw-r--r-- | src/systemctl.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/systemctl.c b/src/systemctl.c index 8f7755f8cb..cf075ed7a3 100644 --- a/src/systemctl.c +++ b/src/systemctl.c @@ -2121,7 +2121,9 @@ static int show(DBusConnection *bus, char **args, unsigned n) { const char *path = NULL; uint32_t id; - if (!show_properties || safe_atou32(args[i], &id) < 0) { + if (safe_atou32(args[i], &id) < 0) { + + /* Interpret as unit name */ if (!(m = dbus_message_new_method_call( "org.freedesktop.systemd1", @@ -2177,7 +2179,9 @@ static int show(DBusConnection *bus, char **args, unsigned n) { } } - } else { + } else if (show_properties) { + + /* Interpret as job id */ if (!(m = dbus_message_new_method_call( "org.freedesktop.systemd1", @@ -2202,6 +2206,33 @@ static int show(DBusConnection *bus, char **args, unsigned n) { r = -EIO; goto finish; } + } else { + + /* Interpret as PID */ + + if (!(m = dbus_message_new_method_call( + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "GetUnitByPID"))) { + log_error("Could not allocate message."); + r = -ENOMEM; + goto finish; + } + + if (!dbus_message_append_args(m, + DBUS_TYPE_UINT32, &id, + DBUS_TYPE_INVALID)) { + log_error("Could not append arguments to message."); + r = -ENOMEM; + goto finish; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) { + log_error("Failed to issue method call: %s", error.message); + r = -EIO; + goto finish; + } } if (!dbus_message_get_args(reply, &error, |