I am having some problems with buffering when reading from a pipe, please help me if you can.
I wrote this simple tool that reads a line from its stdin in a loop, formats it, and outputs it on stdout and in some log file. I made both stdin and stdout linebuffered (the first two lines of code).
Then I run some command that outputs something every second and pipe it through my tool. But instead of outputting line by line the tool still waits until it gets 1024 bytes and then outputs all the lines. All the time that it waits in fgets it is REPLY blocked on /proc/boot/pipe. Using read instead of fgets doesn’t change anything. I have no control over the command whose output I want to catch.
I am running Neutrino 6.2.