[systemd-commits] src/systemctl
Harald Hoyer
harald at kemper.freedesktop.org
Tue Jun 25 04:08:35 PDT 2013
src/systemctl/systemctl.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
New commits:
commit 175728c45fae8a2e1aa9d725ee2fbc7aa34e6dbf
Author: Harald Hoyer <harald at redhat.com>
Date: Tue Jun 25 13:06:51 2013 +0200
systemctl: conform to LSB with the "status" return code
http://fedoraproject.org/wiki/Packaging:SysVInitScript#Exit_Codes_for_the_Status_Action
https://bugzilla.redhat.com/show_bug.cgi?id=975016
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 53033ba..71bf17d 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2658,6 +2658,7 @@ typedef struct UnitStatusInfo {
pid_t main_pid;
pid_t control_pid;
const char *status_text;
+ const char *pid_file;
bool running:1;
usec_t start_timestamp;
@@ -3057,6 +3058,8 @@ static int status_property(const char *name, DBusMessageIter *iter, UnitStatusIn
i->default_control_group = s;
else if (streq(name, "StatusText"))
i->status_text = s;
+ else if (streq(name, "PIDFile"))
+ i->pid_file = s;
else if (streq(name, "SysFSPath"))
i->sysfs_path = s;
else if (streq(name, "Where"))
@@ -3549,7 +3552,16 @@ static int show_one(const char *verb, DBusConnection *bus, const char *path, boo
!streq_ptr(info.active_state, "reloading") &&
streq(verb, "status"))
/* According to LSB: "program not running" */
- r = 3;
+ /* 0: program is running or service is OK
+ * 1: program is dead and /var/run pid file exists
+ * 2: program is dead and /var/lock lock file exists
+ * 3: program is not running
+ * 4: program or service status is unknown
+ */
+ if (info.pid_file)
+ r = 1;
+ else
+ r = 3;
while ((p = info.exec)) {
LIST_REMOVE(ExecStatusInfo, exec, info.exec, p);
More information about the systemd-commits
mailing list