[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Library support for two-phase daemonization
Christos Zoulas wrote:
> - the assumption that pfd + 1 == pfd is not true. If you start
> with 0, 1, 2 open then close 1, and issue pipe(), you'll end up
> with pfd = 1, pfd = 3. So you should test that both pfd
> and pfd are > STDERR_FILENO.
The code is not making that assumption. It is only trying to protect
the write end of the pipe (pfd) 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.
> - 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?
Andreas Gustafsson, gson%gson.org@localhost
Main Index |
Thread Index |