In order to verify in a script that a service is not running I have tried
systemctl is-active some.service
which returns 'inactive' and exit code 3 if the service is not running or it does not exist.
Sometimes however it returns 'unknown' and as well exit code 3, the explanation for that can be found here: https://bugzilla.redhat.com/show_bug.cgi?id=1073481
Status is more complex function with creates a unit in systemd manager. Than you can view its status through is-active until garbage collectors eats it.
So basically, calling something like
systemctl status some.service and the garbage collector both alter the result of
is-active, so it is not reliable.
The recommendation in the same discussion to use
systemctl show some.service -p ActiveState
makes a "stability promise for this command".
However on one system I am getting
Unit some.service could not be found. and exit code 1 for a service that does not exist while on another system I am getting
ActiveState=inactive and exit code 0.
So, how would I check reliably if a service is not running?
If the exit code is not 0 or ActiveState=inactive, is that the whole truth?