read till EOF from stdin
frame
frame86 at live.com
Fri Dec 11 15:57:37 UTC 2020
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.
More information about the Digitalmars-d-learn
mailing list