On Thu, Oct 21, 2010 at 10:39 PM, Jonathan Nieder [off-list ref] wrote:
Erik Faye-Lund wrote:
quoted
I understand that it might be beneficial in the --detach code-path,
but how can stdint, stdout or stderr be closed in this code-path?
Maybe "git daemon >&- 2>&-"?
In some situations involving setuid programs, this kind of thing
can be a security problem (since fd 1 is not taken, the first open()
uses that fd, so output intended for stdout goes to that file).
This is beyond my shell-fu, but if this is supposed to not open
stdin/out/err then I'm a bit puzzled. K&R explicitly states that
stdin, stdout and stderr should be opened at startup in Appendix B:
"When a program begins execution, the tree streams stdin, stdou and
stderr are already open". There's also section 7.5, which lists
redirection to files and pipes as exceptions, but not keeping them
closed.
Perhaps I'm interpreting K&R a little too literary?