From 48196afd2827b36ca5768f886f0866b6dfebdd10 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 3 Sep 2008 20:33:29 -0700 Subject: [PATCH] daemon.c: avoid setlinebuf() This function is outside POSIX (Linux and recent BSD have it). Replace it with setvbuf() which is POSIX. I am not sure about the value this patch passes as size argument to setvbuf(), though. I know the call this patch makes is equivalent to calling setlinebuf() with GNU libc, but POSIX itself leaves what happens to the size argument quite vague, saying only "otherwise [i.e. when buf is a null pointer], size _may_ determine the size of a buffer allocated by the setvbuf() function." If passing size=0 causes stdio to allocate very small buffer, and while stdio tries to line buffer the output, it might make it to fail to buffer an entire line, causing early flushing of the stream. Even if that turns out to be a problem on minorority platforms, we won't know it until the issue actually hurts them, so let's push this change out and see what happens. Signed-off-by: Junio C Hamano --- daemon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/daemon.c b/daemon.c index c315932ce..0e026f65e 100644 --- a/daemon.c +++ b/daemon.c @@ -1083,7 +1083,8 @@ int main(int argc, char **argv) openlog("git-daemon", LOG_PID, LOG_DAEMON); set_die_routine(daemon_die); } else - setlinebuf(stderr); /* avoid splitting a message in the middle */ + /* avoid splitting a message in the middle */ + setvbuf(stderr, NULL, _IOLBF, 0); if (inetd_mode && (group_name || user_name)) die("--user and --group are incompatible with --inetd"); -- 2.30.2