utmpdup: Ensure flushing when using follow flag
The following usages of utmpdump result in no output being flushed to the specified file because the default output buffering is fully buffered: $ utmpdump --follow --output myOutputFile /var/log/utmp $ utmpdump --follow /var/log/utmp > myOutputFile This change configures line buffering for these scenarios so that output will be flushed after each log event. Signed-off-by: Andrew Shapiro <anshapiro@gmail.com>
This commit is contained in:
parent
50cc633257
commit
f3a7b057ac
|
@ -367,6 +367,10 @@ int main(int argc, char **argv)
|
||||||
if (!out)
|
if (!out)
|
||||||
out = stdout;
|
out = stdout;
|
||||||
|
|
||||||
|
if (follow && (out != stdout || !isatty(STDOUT_FILENO))) {
|
||||||
|
setvbuf(out, NULL, _IOLBF, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
filename = argv[optind];
|
filename = argv[optind];
|
||||||
in = fopen(filename, "r");
|
in = fopen(filename, "r");
|
||||||
|
|
Loading…
Reference in New Issue