Issue
I am working now on a macOS Sierra, which does not have the /proc/sys/fs/pipe-max-size nor fcntl's F_SETPIPE_SZ. (Darwin macos-1012 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64)
I am trying to get macOS' log stream
output through pipe()
since I am opening it with execvp()
but I only get its logs when the whole buffer is filled (16384 bytes), this may take hours, days, or more depending on the filter used with log stream
.
When I run log stream
in a command-line it shows log by log and there is no need to wait for the 16384 bytes to be written on STDOUT. But I do have to wait also when I redirect STDOUT as follows:
# log stream --style syslog 1> output.log
And, watching the file with a "tail -f", still get logs only when chunks of 16384 bytes are completed.
This only happens on this macOS version, in higher ones this works fine and every log is flushed immediately, not having to wait for the buffer to be filled.
If someone knows how to solve this or if there is any workaround I will be very grateful.
Thanks in advance!
Solution
You can use command like:
unbuffer log stream --style syslog 1> output.log
the command unbuffer
is part of package expect
Answered By - Romeo Ninov