[radvd-devel-l] Race in PID file creation and daemonizing
Reuben Hawkins
reubenhwk at gmail.com
Wed Apr 4 08:41:06 EDT 2012
Libdaemon sounds interesting. Let's go that route.
Sent from my iPhone
On Apr 4, 2012, at 4:38 AM, Petr Pisar <ppisar at redhat.com> wrote:
> Hello,
>
> 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)
> perror("daemon");
> }
> }
>
> write_pid_file(pidfile);
>
> 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
> --
> radvd-devel-l mailing list : radvd-devel-l at litech.org
> http://lists.litech.org/listinfo/radvd-devel-l
More information about the radvd-devel-l
mailing list