From ffdde63ecc83100166468fbc86257ee30da4c9c3 Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Tue, 11 Jun 2013 17:04:59 +0200 Subject: [PATCH] Use line buffering on log files. This makes sure the contents are written on the disk, so the user can read the log. --- shairport.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shairport.c b/shairport.c index f5906e7e..11377b1e 100644 --- a/shairport.c +++ b/shairport.c @@ -216,8 +216,13 @@ void log_setup() { die("Could not open logfile"); dup2(log_fd, STDOUT_FILENO); + setvbuf (stdout, NULL, _IOLBF, BUFSIZ); + if (!config.errfile) + { dup2(log_fd, STDERR_FILENO); + setvbuf (stderr, NULL, _IOLBF, BUFSIZ); + } } if (config.errfile) { @@ -228,6 +233,7 @@ void log_setup() { die("Could not open logfile"); dup2(err_fd, STDERR_FILENO); + setvbuf (stderr, NULL, _IOLBF, BUFSIZ); } }