<div dir="ltr">How can I trace what sd_notify(3) calls a program makes?<div><br></div><div>Obviously, I don't have the source, and running <b>strings</b> on it does reveal a <b>READY=1</b> line, but it is unclear whether the code makes it to the point where that gets sent.</div><div><br></div><div>Here is what I am *really* trying to accomplish; maybe I am going about it the wrong way:</div><div><br></div><div>I have some vendor code that is invoked by the following service file:</div><div><br></div><div><b>[<font face="monospace">Service]<br>ExecStart=/opt/vendor/bin/foo<br>Restart=always<br>User=root<br>Type=notify<br>NotifyAccess=exec<br>TimeoutStopSec=86400</font></b><br></div><div><br></div><div>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:</div><div><br></div><div><font face="monospace"><b>#!/bin/sh<br>/opt/vendor/bin/foo &<br>pid=$!<br>echo $pid > /run/foo.pid<br>wait</b></font><br><br></div><div>and change the [Service] part of the service file to:</div><div> </div><div><b>[<font face="monospace">Service]<br>ExecStart=/usr/local/sbin/run-foo.sh<br>Restart=always<br>User=root</font></b></div><div><b><font face="monospace">Type=notify<br>NotifyAccess=all<br>TimeoutStopSec=86400</font></b><br></div><div><br></div><div><br></div><div>the idea being that the original program will still send the <b>sd_notify(),</b> and I would have its pid.<br><br>However, this is not happening; <b>systemctl start foo.service </b>hangs for about 30s, and then exits with:</div><div><br></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0)">Job for foo.service failed because a timeout was exceeded.
</span><br>See "systemctl status foo</span><span style="font-family:monospace">.service" and "journalctl -xe" for details.</span></div><div><span style="font-family:monospace"><br></span></div>The relevant lines are:<div><span style="font-family:monospace"><span style="color:rgb(0,0,0)">systemd[1]: </span><span style="font-weight:bold;color:rgb(215,215,95)">foo.service: start operation timed out. Terminating.</span><br></span></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0)">systemd[1]: </span><span style="font-weight:bold;color:rgb(0,0,0)">foo.service: Main process exited, code=exited, status=143/n/a</span><br></span></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0)">systemd[1]: </span><span style="font-weight:bold;color:rgb(215,215,95)">foo.service: Failed with result 'timeout'.</span><br></span></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0)">systemd[1]: </span><span style="font-weight:bold;color:rgb(255,84,84)">Failed to start Foo.</span><br></span></div><br>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.<div><br></div><div>Help?</div><div><br></div><div>Thanks,</div><div><br></div><div>/ji</div></div>