[systemd-devel] How to run forking daemon with systemd in correct way, without errors?

Mantas Mikulėnas grawity at gmail.com
Thu Nov 23 05:45:47 UTC 2017


On Wed, Nov 22, 2017 at 10:37 PM, Gena Makhomed <gmm at csdoc.com> wrote:

>
> This is bug in nginx code? And this bug should be fixed in nginx?
>
> But "daemon(); write_pidfile();" is common pattern
> used by many services and even in library functions.
>
>
It may be common, but not necessarily correct. The parent process should
only exit *after* finishing all the preparations (i.e. something like
"fork(); write_pidfile(); exit()"), since systemd uses the exit as a signal
that the daemon is now "ready".

-- 
Mantas Mikulėnas <grawity at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20171123/fea87f57/attachment.html>


More information about the systemd-devel mailing list