On Mi, 22.11.17 22:37, Gena Makhomed ([email protected]) wrote: > But nginx is forking daemon - when start process exited - > no warranty what pidfile already created by child process. > > This is bug in nginx code? And this bug should be fixed in nginx?
Yes, and that's not just broken in the context of systemd, but on SysV services, too. Think "/etc/init.d/nginx start ; /etc/init.d/nginx stop" — if the PID file is not written fully by the time nginx forked and the parent exited, then such a stop immediately following will fail too... Daemons need to either write the PID file in the parent, after forking off the daemon, and before exiting, or the daemon process can do that, but then there needs to be some form of synchronization that makes sure that the parent doesn't exit before the daemon process finished writing the PID file. This is documented in daemon(7) btw: https://www.freedesktop.org/software/systemd/man/daemon.html > But "daemon(); write_pidfile();" is common pattern > used by many services and even in library functions. Yeah, and it's too simplistic unfortunately. > ExecStop=/bin/kill -s TERM $MAINPID This line is redundant btw, systemd does that anyway. Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/systemd-devel
