Posts

Showing posts from April 26, 2019

How does a program know if stdout is connected to a terminal or a pipe?

Image
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0; } 1 0 I'm having trouble debugging a segfaulting program because the ouput right before the segfault is what I need, but this is lost if I'm piping the output to a file. According to this answer: https://unix.stackexchange.com/a/17339/22615, this is because the output buffer of the program flushes immediately when connected to a terminal but only at certain points when connected to a pipe. A few questions here: How does a program determine what its stdout is connected to? How does the "script" command produce the same behavior as when the program writes to a terminal? Can this be achieved without the script command? ...
2qM85hFd1Qi5m,qP4IsWZIP1,DXoMkZjW1,f QJRL2mCCb39 kTB md5YEEOub om,Sp5DE3OlVc1zb6ylwvnFp9N8 k,o2RpOLc,p4Pa a6