On Tue, Sep 12, 2017 at 08:24:15PM +0000, hyc@symas.com wrote:
I don't have documentation for sd_notify() on my machine
https://www.freedesktop.org/software/systemd/man/sd_notify.html
- what does it return if systemd isn't running at the moment? What does
it return if the current program wasn't started by systemd (and thus, the notification is irrelevant)?
0 in both of these cases (assuming there is not an unrelated NOTIFY_SOCKET env var). However, it also says:
In order to support both service managers that implement this scheme and those which do not, it is generally recommended to ignore the return value of this call."
and the current patch doesn't follow that recommendation, since it does check the return value. I don't feel strongly either way about that.
It strikes me that this code should only be invoked if slapd was actually started by systemd.
As I understand it, sd_notify() should be a no-op (no error) if NOTIFY_SOCKET is not set. I don't think we should check NOTIFY_SOCKET ourselves; it's to some extent an implementation detail.