[systemd-devel] [PATCH] Return error code 3 with systemctl status after killall LSB server

Steven Dake sdake at redhat.com
Fri Jul 1 00:00:51 PDT 2011


This patch is probably not correct, but not having a clear
understanding of the systemd states, I'm not sure how to properly
fix the problem.

The test case is as follows:
service httpd start
killall httpd
service httpd status
echo $?
(0 printed, 3 should be printed according to LSB)

Then attempting to start the service again does not allow it to be
started, likely because its in the "active" state.  I would expect
it would be in some other state besides active, such as failed,
atleast for LSB scripts.

Signed-off-by: Steven Dake <sdake at redhat.com>
---
 src/systemctl.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/systemctl.c b/src/systemctl.c
index f6dca5b..93f4fda 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -2614,9 +2614,11 @@ static int show_one(const char *verb, DBusConnection *bus, const char *path, boo
         if (!show_properties)
                 print_status_info(&info);
 
-        if (!streq_ptr(info.active_state, "active") &&
+        if ((!streq_ptr(info.active_state, "active") &&
             !streq_ptr(info.active_state, "reloading") &&
-            streq(verb, "status"))
+            streq(verb, "status")) ||
+            (streq_ptr(info.active_state, "active") &&
+            streq_ptr(info.sub_state, "exited")))
                 /* According to LSB: "program not running" */
                 r = 3;
 
-- 
1.7.4.4



More information about the systemd-devel mailing list