On Sat, May 28, 2022 at 03:33:16AM +0000, Rodrigo Martins wrote: > Hello, > > The problem here is I/O buffering. I suspect it to happen in the C standard > library, specifically on the printf function family. If I recall, the C > standard says stdio is line-buffered when the file is an interactive device > and let's it be fully buffered otherwise. This is likely why you see > different behavior with and without less on the pipeline. > I don't yet have a clear solution to this problem that doesn't involve > modifying each program in the pipeline, but I've annexed a C source as an > example that may be used in place of tr to replace single chars. This program > is not supposed to buffer any I/O. > I see tee "shall not buffer output". Another possibility is the setbuf > function, but I'm not sure it can be used without editing each program. More > investigation is needed. > > Rodrigo.
You can use stdbuf(1) to modify that aspect without touching the program source itself.