[systemd-devel] Antw: [EXT] [systemd‑devel] PIDFile creation logic
Ulrich Windl
Ulrich.Windl at rz.uni-regensburg.de
Tue Oct 19 08:20:46 UTC 2021
>>> Kenneth Porter <shiva at sewingwitch.com> schrieb am 18.10.2021 um 21:43 in
Nachricht <95B112234248FF54AD014623@[192.168.1.16]>:
> I just installed the new‑to‑EPEL ndppd service and am seeing this in my
log:
>
> Oct 17 21:10:08 saruman systemd: Can't open PID file
> /var/run/ndppd/ndppd.pid (yet?) after start: No such file or directory
>
> Examining the source, I see that the pidfile is created by the child
> process, not the parent. I'm guessing that systemd is expecting the pidfile
> to exist when the parent exits? (I want to file the issue on the upstream
> program and want to make sure I understand how this should work.)
>
> Source in question. Note how daemonize() forks and exits and main() invokes
> daemonize and then creates the pidfile. I'm thinking that daemonize()
> should create the pidfile before it invokes exit().
>
> <https://github.com/DanielAdolfsson/ndppd/blob/master/src/ndppd.cc>
I had the same incompatibility problem in my own daemon, and the fix was like
this (still somewhat inefficient):
...
else if ( pid == 0 )
{
/* wait for parent to exit */
while ( getppid() != 1 )
milli_sleep(5);
/* child continues */
...
Regards,
Ulrich
More information about the systemd-devel
mailing list