[systemd-devel] In OnFailure, the result is always "signal" unless KillMode=none

Borislav Trifonov btrifonov at macroh.com
Wed Dec 16 12:53:53 PST 2015


Resending, sans HTML...

Hi, I have the script run by an OnFailure unit to send some data over the net‎work, including whether the failure was due to a crash or watchdog timeout (I'm using WatchdogSec and sd_notify()). I use "systemctl show %i --property=ActiveStatus,Result" to retrieve what happened. However, I always get "signal". It seems that the kill gets sent before OnFailure runs. Once I set KillMode=none, then if it's a watchdog timeout, I do get Result to be "watchdog" so that's a workaround.

The problem with that workaround is that if I set KillMode=none, I have to now kill the process in the script the OnFailure unit runs. This introduces races with systemctl start and stop commands being sent by another process that does complex scheduling--because now the service can be in a failed state while the process has not been killed, and a systemctl start received in that time window will cause a new instance of the process to start before the old one has been killed, which is a problem in my application. So is there any way to have it both ways, having KillMode kill the process but also being able to know whether failure was due to the process hanging vs crashing, without having to parse the journal?




More information about the systemd-devel mailing list