tech-userlevel archive

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

Re: Library support for two-phase daemonization

In article <>,
Andreas Gustafsson  <> wrote:
>Christos Zoulas wrote:
>> - the assumption that pfd[0] + 1 == pfd[1] is not true. If you start
>>   with 0, 1, 2 open then close 1, and issue pipe(), you'll end up
>>   with pfd[0] = 1, pfd[1] = 3. So you should test that both pfd[0]
>>   and pfd[1] are > STDERR_FILENO.
>The code is not making that assumption.  It is only trying to protect
>the write end of the pipe (pfd[1]) from getting a fd in the range 0-2,
>not the read end, as the read end will be closed anyway by the time
>the child closes fds 0-2.

Ok, sounds good.

>> - I think most fd's should be close on exec here. so you could use pipe2()
>>   to setup sigpipe and close-on-exec handlign.
>> - results of read/write are ssize_t
>> - I like to write fork as a switch instead of ifthenelif, r is pid_t.
>> - why isn't the detach daemon pipe static?
>I'll fix these.
>Implementation nits aside, do you find the API acceptable, or would
>you prefer to expose the file descriptor as Joerg is suggesting?

I think that exposing the file descriptor is nice because it avoids the
static storage issue.


Home | Main Index | Thread Index | Old Index