From: Roy Marples Date: Mon, 28 Jul 2008 15:43:38 +0000 (+0000) Subject: Use setlinebuf() at startup instead of calling fflush() for each logger call. X-Git-Tag: v4.0.2~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a2cb5bcaf1cc7709204800129aeb8e203e4bbf3;p=thirdparty%2Fdhcpcd.git Use setlinebuf() at startup instead of calling fflush() for each logger call. --- diff --git a/dhcpcd.c b/dhcpcd.c index 3857b7c5..92813fc2 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -627,6 +627,9 @@ main(int argc, char **argv) #endif closefrom(3); + /* Saves calling fflush(stream) in the logger */ + setlinebuf(stdout); + setlinebuf(stderr); openlog(PACKAGE, LOG_PID, LOG_LOCAL0); setlogprefix(PACKAGE ": "); diff --git a/logger.c b/logger.c index 6eb0c295..f312679a 100644 --- a/logger.c +++ b/logger.c @@ -90,10 +90,6 @@ logger(int level, const char *fmt, ...) fprintf(f, "%s", logprefix); vfprintf(f, fmt, p); fputc('\n', f); - - /* stdout, stderr may be re-directed to some kind of buffer. - * So we always flush to ensure it's written. */ - fflush(f); } if (level < LOG_DEBUG || level <= loglevel) {