[systemd-devel] what is sd_notify() really for ?

Lennart Poettering lennart at poettering.net
Mon Apr 17 09:32:39 UTC 2017


On Mon, 17.04.17 00:47, Enrico Weigelt, metux IT consult (enrico.weigelt at gr13.net) wrote:

> On 17.04.2017 00:04, Lennart Poettering wrote:
> 
> > Please always check the man pages if you have questions regarding a
> > specific systemd interface:
> > 
> > https://www.freedesktop.org/software/systemd/man/sd_notify.html
> 
> Done so, of course. Unfortunately, it doesn't answer my questions,
> eg. what the service manager actually does w/ that information.

Well, it's used for a variety of things. I figure most relevant usage
is for the implementation of Type=notify services, which is referenced
from the man page, if you have a look. For details about that option
see:

https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=

Another major use is for the watchdog logic, i.e. the implementation
of the WatchdogSec= setting, also referenced from sd_notify()'s man
page. For details about this specific setting see:

https://www.freedesktop.org/software/systemd/man/systemd.service.html#WatchdogSec=

And there's more. For example, you can use it to store fds in the
service manager, so that your service may be restarted (or terminated
abnormally) and access to specific sockets, devices, or any other
object that may be referenced with a file descriptor isn't lost.

If the brief descriptions in the man pages aren't sufficient, I'd
recommend you to have a look at the sources.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list