tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Library support for two-phase daemonization



On Tue, 28 Jan 2014, Andreas Gustafsson wrote:

> I think the right way to fix the problem is to split the daemonization
> into two phases: the daemon should fork early, before creating threads
> or kqueues, but the parent process should only exit when the child is
> ready to accept requests for service.

btw I did this in btpand(8), which uses libevent (and thus kqueue)

> The patch includes updates to the daemon(3) man page and test cases.
> Initially, two daemons would be switched to the new scheme: nfsd and
> rquotad (the ones involved in the test failures reported in PR 48282);
> others can follow later.
>
> Comments?

one minor nit from me is that syscalls such as pipe(2), fork(2) and
read(2) return "-1" for error according to the manpages .. using a test
for "< 0" to detect that never seems right to me, especially when casting
from a different type which could involve a truncation (eg ssize_t)

Also, I agree with christos that a switch is better :)

iain


Home | Main Index | Thread Index | Old Index