On 7/27/20 6:33 AM, Dominique Martinet wrote:
It's interesting to see an application actually does open regular files
with O_NONBLOCK; when this was discussed in the pull request[2]
basically the agreement was that apps should either just not be setting
nonblock (which ought to be no-op on regular files),

O_NONBLOCK is needed there because the file might be a FIFO or a special file, and 'tar' doesn't want to hang forever trying to open the file. And 'tar' shouldn't stat the file first to see whether the file is a FIFO or a special file, as that (a) would be slower and (b) would introduce a race condition.

or would handle
short reads so it would probably be fineā„¢
(But I guess life always proves us wrong, sorry for the trouble)

Yes, POSIX requires that you don't get a short read when you're reading a regular file (unless it's at EOF or you're interrupted by a signal), and I assume 'tar' and other programs use this to avoid an unnecessary read of 0 bytes at end of file.

Reply via email to