On Sun, Aug 28, 2016 at 02:21:47PM +0100, Jonathan de Boyne Pollard wrote:
> Simon McVittie:
> >You mean like libsystemd, which looks in /run to see whether systemd is in
> >use, talks to it if it is, and returns some suitable error code (-ENOSYS?)
> >if it isn't? :-)
> Here's interesting for you. (-:
> Here's libsystemd and Arturo Borrero Gonzalez's code that calls it. Please
> point to the line that checks in /run for systemd running.
> * https://github.com/formorer/pkg-conntrack-tools/blob/1ed72f0e691bbd92a78a0a944a9c448260e6ff41/src/systemd.c#L30
> * https://github.com/systemd/systemd/blob/master/src/libsystemd/sd-daemon/sd-daemon.c#L404
It's possible to use sd_booted() to check that. In practice, sd_notify
does nothing if NOTIFY_SOCKET isn't set in the environment (lines
432-434 in the latter link, at the moment), so I'm not sure if one needs
to bother in practice, but the option is certainly there.
Anyway, the spirit of Simon's remark is true even if details were a bit
off. Merely using libsystemd for sd_notify or similar doesn't make
daemon code systemd-specific.
Colin Watson [firstname.lastname@example.org]