On Sat, May 28, 2022 at 07:58:40PM +0200, Markus Wichmann wrote: > > You can use stdbuf(1) to modify that aspect without touching the > > program source itself. > > > > Had to look up the source for that. I had heard of stdbuf, but I always > thought that that was impossible. How can one process change a > process-internal detail of another program? One that is not inherited > through fork() or exec(), I mean. Well, turns out it is impossible. > stdbuf sets LD_PRELOAD and execs the command line, and the changing of > the buffer modes happens in the library. > > That means that whole thing only works if: > - you have the target program linked dynamically > - you have stdbuf and the target program linked against the same libc > - the target program doesn't change buffering modes later, anyway > - the target program does not have elevated privilege. >
You know what, thanks for looking it up, I also thought it was using some kind of fork or ptrace hack. The man page doesn't even mention this =( Now, I wonder how it'd be fixed ("it" being how does the read end of the pipe signal to the write one the kind of buffering it wants) in a perfect world. An environment variable read by the libc would work but is kind of ugly. A pipe flag together with a special sh syntax would be even uglier. Hmmmm.