Skip to content

Commit 19effa1

Browse files
amirrossertphilpep
authored andcommitted
Add 4 to the expected exit code when running "systemctl is-active"
Signed-off-by: Amir Rossert <[email protected]>
1 parent fc53e20 commit 19effa1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: testinfra/modules/service.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,13 @@ def exists(self):
181181

182182
@property
183183
def is_running(self):
184-
out = self.run_expect([0, 1, 3], "systemctl is-active %s", self.name)
184+
# based on https://man7.org/linux/man-pages/man1/systemctl.1.html
185+
# 0: program running
186+
# 1: program is dead and pid file exists
187+
# 3: not running and pid file does not exists
188+
# 4: Unable to determine status (no such unit)
189+
out = self.run_expect([0, 1, 3, 4], "systemctl is-active %s",
190+
self.name)
185191
if out.rc == 1:
186192
# Failed to connect to bus: No such file or directory
187193
return super().is_running

0 commit comments

Comments
 (0)