gstr...@elektromaniak.wz.cz writes: > I am really curious what the rationale behind the fflush was.
The rationale was the data is not of much use to anyone while lingering in Wget's stdio buffer. No one else sees it, and if you only press ^C, you lose it permanently. Wget is not asking for the data to be immediately written out to disk, it is merely handing it off to the operating system, so other programs (be it tail -f or a locally running browser) can see it and put it to good use. fflush != fsync. Plus, typical stdio buffer is smaller than Wget's network read buffer, so most of the data would have been flushed anyhow. The fflush() only makes sure that by the time Wget announces that it has downloaded (say) 123,456 bytes of data, your file contains no *less* than 123,456 bytes. If some misconfigured system were really neglecting to cache filesystem writes, then it would have problems with most programs out there, not just Wget. After all, BUFSIZ on a typical system is only 4-8K.