[systemd-devel] PIDFile creation logic

Cristian Rodríguez crrodriguez at opensuse.org
Mon Oct 18 21:05:53 UTC 2021


On Mon, Oct 18, 2021 at 4:44 PM Kenneth Porter <shiva at sewingwitch.com> wrote:
>
> 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>

the steps needed for this to work are clearly documented : man 7
daemon, section sysv daemons,
unfortunately I am yet to see any software in the wild doing this right..
but it doesn't matter. just..don't. execstart this program without -d
or -p switches, set the service Type= exec

Now.. you might consider networkd instead too.


More information about the systemd-devel mailing list