[systemd-devel] Debugging sd_notify / tracing notifications?

John Ioannidis systemd-devel at tla.org
Mon Mar 1 15:20:31 UTC 2021


How can I trace what sd_notify(3) calls a program makes?

Obviously, I don't have the source, and running *strings* on it does reveal
a *READY=1* line, but it is unclear whether the code makes it to the point
where that gets sent.

Here is what I am *really* trying to accomplish; maybe I am going about it
the wrong way:

I have some vendor code that is invoked by the following service file:







*[Service]ExecStart=/opt/vendor/bin/fooRestart=alwaysUser=rootType=notifyNotifyAccess=execTimeoutStopSec=86400*

I occasionally need to send a SIGINT to the process, but finding it with
the equivalent of ps ax | grep foo is annoying and maybe not terribly
reliable. My first workaround was to create this script:





*#!/bin/sh/opt/vendor/bin/foo &pid=$!echo $pid > /run/foo.pidwait*

and change the [Service] part of the service file to:




*[Service]ExecStart=/usr/local/sbin/run-foo.shRestart=alwaysUser=root*


*Type=notifyNotifyAccess=allTimeoutStopSec=86400*


the idea being that the original program will still send the *sd_notify(),* and
I would have its pid.

However, this is not happening; *systemctl start foo.service *hangs for
about 30s, and then exits with:

Job for foo.service failed because a timeout was exceeded.
See "systemctl status foo.service" and "journalctl -xe" for details.

The relevant lines are:
systemd[1]: foo.service: start operation timed out. Terminating.
systemd[1]: foo.service: Main process exited, code=exited, status=143/n/a
systemd[1]: foo.service: Failed with result 'timeout'.
systemd[1]: Failed to start Foo.

Clearly I'm misunderstanding something about how sdnotify is supposed to
work. It would also help if I could *see* what is actually being sent.

Help?

Thanks,

/ji
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210301/71106352/attachment-0001.htm>


More information about the systemd-devel mailing list