On Friday, 11 December 2020 at 12:34:19 UTC, kdevel wrote:
My code cannot do that because the function byChunk has control
over the
file descriptor.
What do you mean by control? It just has the file handle, why do
you cannot call eof() on the file handle struct?
You should not check yourself for the character.
Where did I do that here?
I was just assuming that...
eof() can be lock in by multiple ways and it is the only
correct way to handle all of them.
??
I mean that it's safer to rely on eof() which should return true
if the stream comes inaccessible, caused by read(2) or whatever
other OS depended reasons.
...but I was looking in the source and...
yes, byChunk() seems not to care about eof() - but it will just
truncate the buffer on read failure which should work for your
case. It basically just calls C's fread().
Are you sure that read(0, "", 1024) trace cones from your ctrl+d?
It could be also from the runtime checking if the handle can be
closed or something.
Please note that your terminal could be also the issue.