[radvd-devel-l] Race in PID file creation and daemonizing

Petr Pisar ppisar at redhat.com
Wed Apr 4 07:38:32 EDT 2012


I've been reported <https://bugzilla.redhat.com/show_bug.cgi?id=664783> there
is race between deamonizing and creating PID file.

Current code is:

    if (get_debuglevel() == 0) {

        if (daemonize) {
            /* Detach from controlling terminal */
            if (daemon(0, 0) < 0)


Which allows exiting executed radvd process before the PID file is created and
filled with a PID number.

This can cause troubles to init scripts which wait for the process or inspect
the PID file. (E.g. /etc/init.d/radvd start; /etc/init.d/radvd status.)

I'd like to fix it.

The daemon(3) function must be replaced with something which can synchronize
PID file writing to daemonization.

I'm thinking about manual implementation (pipe, fork, setsid, fork, exit,
synchronize through pipe, write PID file, exit) or using libdaemon library for
that purpose. Which way is acceptable for radvd maintainer?

-- Petr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 230 bytes
Desc: not available
URL: <http://lists.litech.org/pipermail/radvd-devel-l/attachments/20120404/fae83107/attachment.pgp>

More information about the radvd-devel-l mailing list