@matheusbsbs / matheus-bagliano / commits / 48cfaea108
Fork 0

daemon: use full buffered mode for stderr

Windows doesn't support line buffered mode for file streams, so let's just use full buffered mode with a big buffer ("4096 should be enough for everyone") and add explicit flushing. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Erik Faye-Lund committed Nov 4, 2010 at 02:35 UTC 48cfaea10879790ba6d2c8b566a0df75c411672d
1 file changed +4 -2
daemon.c
+4 -2
@@ -67,12 +67,14 @@ static void logreport(int priority, const char *err, va_list params)
67 syslog(priority, "%s", buf);
68 } else {
69 /*
70 - * Since stderr is set to linebuffered mode, the
70 + * Since stderr is set to buffered mode, the
71 * logging of different processes will not overlap
72 + * unless they overflow the (rather big) buffers.
73 */
74 fprintf(stderr, "[%"PRIuMAX"] ", (uintmax_t)getpid());
75 vfprintf(stderr, err, params);
76 fputc('\n', stderr);
77 + fflush(stderr);
78 }
79 }
80
@@ -1117,7 +1119,7 @@ int main(int argc, char **argv)
1119 set_die_routine(daemon_die);
1120 } else
1121 /* avoid splitting a message in the middle */
1120 - setvbuf(stderr, NULL, _IOLBF, 0);
1122 + setvbuf(stderr, NULL, _IOFBF, 4096);
1123
1124 if (inetd_mode && (group_name || user_name))
1125 die("--user and --group are incompatible with --inetd");