Skip to content

Commit 48196af

Browse files
committed
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 <gitster@pobox.com>
1 parent 80d12c2 commit 48196af

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

daemon.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,8 @@ int main(int argc, char **argv)
10831083
openlog("git-daemon", LOG_PID, LOG_DAEMON);
10841084
set_die_routine(daemon_die);
10851085
} else
1086-
setlinebuf(stderr); /* avoid splitting a message in the middle */
1086+
/* avoid splitting a message in the middle */
1087+
setvbuf(stderr, NULL, _IOLBF, 0);
10871088

10881089
if (inetd_mode && (group_name || user_name))
10891090
die("--user and --group are incompatible with --inetd");

0 commit comments

Comments
 (0)