What happens to stdout when a script runs a program?
have an embedded application and I want a simple-minded recorder.
The system starts with a script file, which in turn runs the application. There can be several reasons why a script might not run an application, or the application itself might not start. To diagnose this issue remotely, I need to see standard output from scripts and applications.
I tried writing a TEE-like logger that repeats its standard input to standard output and saves the text in the FIFO for later retrieval over the network. Then I naively tried it
./script | ./logger
I ended up with only script standard output going into the logger and application standard output disappearing. I got similar results when I tried to serve.
The system is running kernel 2.4.26 and busybox.
What happened and how can I get there?
It turned out it worked exactly as I expected, but with one minor issue. stdout is being buffered and there isn’t any fflush(stdout) command, I’ve never seen it. If I were really patient, I would suddenly see a lot of output when the stdout buffer fills up. Calling setlinebuf(3) solved my problem.