From: Erik Faye-Lund Date: Thu, 21 Oct 2010 20:54:33 GMT Subject: Re: [PATCH v4 15/15] daemon: opt-out on features that require posix Message-ID: In-Reply-To: <20101021203926.GB12685@burratino> On Thu, Oct 21, 2010 at 10:39 PM, Jonathan Nieder wrote: > Erik Faye-Lund wrote: > >> 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?