[systemd-devel] option to wait for pid file to appear

Lennart Poettering lennart at poettering.net
Thu Jun 7 08:35:09 UTC 2018


On Do, 07.06.18 09:50, Igor Bukanov (igor at mir2.org) wrote:

> On 18 May 2018 at 19:37, Lennart Poettering <lennart at poettering.net> wrote:
> > On Do, 17.05.18 22:54, Igor Bukanov (igor at mir2.org) wrote:
> > Well, no. The protocol is clear, and what we do is pretty close to
> > black magic, and still racy in many ways.
> >
> > I mean, broken behaviour is still broken behaviour, even if we
> > nowadays handle it pretty nicely. Really, nginx should be fixed,
> > everybody benefits, sysvinit as much as we do.
> 
> It turned out it is not only nginx that behaves this way. Any program
> that is using the daemon(3) call available both in Linux and BSD
> writes the pid from the child without the parent waiting. So this
> behaviour must be widespread and as such I think must be accepted as a
> de-facto standard (even if it is unfortunate) and systemd should not
> even warn about it.

Nah, daemon() does not write PID files, you have to do that in your
own code. The fact that much code doesn't synchronize properly around
that is really a bug in that code. I mean, you can get away with using
daemon() as long as you synchronize around it, for example by first
allocating some pipe(), then waiting on it in the parent, and
signalling it from the child after having written the PID file...

Again, not synchronizing properly is broken for sysvinit as much as it
is broken for systemd. We deal with it to some point, but the only
fully safe and correct way to handle this is to fix the programs in
question.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list