From: Junio C Hamano Date: Tue, 06 Dec 2022 23:39:35 GMT Subject: Re: [PATCH] setup: avoid unconditional open with write flags Message-ID: In-Reply-To: René Scharfe writes: > Can opening /dev/null (or NUL on Windows) multiple times instead of dup'ing > cause issues? Can we e.g. lock ourselves out? 258e93a1 (daemon: if one of the standard fds is missing open it to /dev/null, 2006-07-13) unfortunately does not explain why it was done this way. Given that "command /dev/null 2>/dev/null" should work fine, I suspect that the "once we open a throw-away descriptor, instead of opening the same file again, dup the fd and reuse" was done not for correctness but for performance, under the assumption that open() is more expensive?