[systemd-devel] possible bug guessing mainpid when service type=forking..
Marius Tolzmann
tolzmann at molgen.mpg.de
Tue Jun 21 09:50:01 PDT 2011
hi..
On 06/20/11 21:36, Lennart Poettering wrote:
>
> This very much sounds as if the service does not wait in the top-level
> process that the daemon process is properly forked and finished writing
> the PID file. systemd tries to read the PID file immediately after the
> top-level process exits which means that systemd will race against the
> daemon there.
>
> So my guess is that ypbind-mt does something like this:
>
> fork() --> fork() --> write_pid_file()
> exit() exit() run_main_loop()
thats it..
> but it should be doing:
>
> fork() ------------> fork() --> write_pid_file()
> wait_for_notify() exit() notify_grandparent()
> exit() run_main_loop()
> ...
the run-in-foreground patch works fine.. and as far as i understood
Type=forking is just good for compatibility and daemons should not fork
away anymore!?
> i.e. the main process should not exit before it hasn't ensure that the
> PID file of the daemon process has been written. Otherwise any usage of
> the PID file is necessarily racy.
but it doesn't work without setting PIDFile= either - so the PID itself
is racy, too.
>> BTW a patch for ypbind-mt adding a -foreground commandline switch will
>> be sent to the maintainers soon..
>
> Nice, this is good to hear, Type=simple is definitely the ncier solution.
may be it could be mentioned in the manpage where Type=forking is
explained that there could be a race if the daemon is forking twice or
if it behaves odd in another way.. - GuessMainPID= already states that
it may not work reliable..
there was nothing written to the logs that pointed in that direction and
increasing verbosity changed everything 8) tricky situation and i think
systemd should not be blamed for this.. ever 8)
bye marius..
--
Dipl.-Inf. Marius Tolzmann <marius.tolzmann at molgen.mpg.de>
----------------------------------.------------------------------
MPI f. molekulare Genetik |
Ihnestrasse 63-73, D-14195 Berlin | ==> MarIuX GNU/Linux <==
Phone: +49 (0)30 8413 1709 |
----------------------------------^------------------------------
God put me on earth to accomplish a certain number of things.
Right now I am so far behind..
..I will never die. <by calvin from calvin&hobbes ;)>
More information about the systemd-devel
mailing list