Skip to contentSkip to conversation

daemonlib: Update docs

PATCH New Petr Vorel 2 participants 3 messages Mar 9, 2017

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/2 daemonlib: Update docs

---
 doc/test-writing-guidelines.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/test-writing-guidelines.txt +1 -1
index 4256427f2..521773b4f 100644
@@ -1796,7 +1796,7 @@ correct daemon name.
 | start_daemon()   | Starts daemon, name is passed as first parameter.
 | stop_daemon()    | Stops daemon, name is passed as first parameter.
 | restart_daemon() | Restarts daemon, name is passed as first parameter.
-| status_daemon()  | Returns daemon status, TODO: what is return value?
+| status_daemon()  | Detect daemon status (exit code: 0: running, 1: not running).
 |==============================================================================
 
 .Variables with detected names
Signature · 1 line
2.12.0
author
#1 lore raw

PATCH 2/2 daemonlib: Use is-active instead of status for systemctl

'systemctl status service' exit code is broken in old distros. It returns 0 even if service is not running. As we use status_daemon for detecting whether service is running, it's more reliable to use is-active.

systemctl bug was introduced in systemd v209 (f74294c1d), fixed in v213 (5bb75bc74).

---
 testcases/lib/daemonlib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/lib/daemonlib.sh +1 -1
index 2dcb1554d..0de3f86af 100644
@@ -69,7 +69,7 @@ stop_daemon()
 status_daemon()
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
-		systemctl status $1.service > /dev/null 2>&1
+		systemctl is-active $1.service > /dev/null 2>&1
 	elif command -v service >/dev/null 2>&1; then
 		service $1 status > /dev/null 2>&1
 	else
Signature · 1 line
2.12.0