Hacker News new | ask | show | jobs
by sltkr 1014 days ago
My favorite tool that (ab)uses LD_PRELOAD to do something useful is `stdbuf`: https://linux.die.net/man/1/stdbuf

The implementation is completely bonkers. The tool sets some environmental variables, then spawns a child process with LD_PRELOAD set to load a library (libstdbuf.so) which has a some initialization code that runs when the library is loaded, and that based on the environmental variables, calls setvbuf() from inside the child process to override the buffering behavior.