News for hackers. Stuff that matters.
Re:How is GNU `yes` so fast? by zakk on Tuesday June 13, 2017 @07:10AM (#14543978)
I am wondering why the GNU version uses

atexit (close_stdout);

Aren't all streams closed at exit? And why closing stdout, anyway?

Re:How is GNU `yes` so fast? by tyingq on Tuesday June 13, 2017 @07:58AM (#14544133)
It's to make sure the buffer is flushed. Streams are closed, but not explicitly flushed at exit. Stdout only because it's the only filehandle with a buffer in yes.
Re:How is GNU `yes` so fast? by LukeShu on Tuesday June 13, 2017 @03:52PM (#14548024)
In normal use, GNU `yes` does unbuffered IO on stdout. However, it does use buffered IO for --help and --version messages; it sets atexit(close_stdout) to cover both of those cases at once, rather than handling them both separately.