read() from a removed device

Florian Weimer
Mon Jul 6 17:54:44 GMT 2020

* Frank Schäfer:

> Am 06.07.20 um 19:17 schrieb Florian Weimer:
>> * Frank Schäfer via Libc-help:
>>> I just noticed that read() from a usb-serial device doesn't fail after
>>> the device got (physically) removed.
>>> I would expect it to return -1 and set an appropriate errno, but it
>>> returns 0 (no error, no bytes read) instead.
>>> Is this the correct/expected behavior or a bug ?
>> You need toask on one of the kernel mailing lists.  glibc just calls
>> into the kernel and reports back whatever it receives from there.

> Guess what the kernel devs say when I report this issue to them... ;)

Not sure what exactly you asked.  Maybe someone confused fread and read.

> How does the "call into the kernel" look like ?

Basically like this:

  xor %eax, %eax

Plus some code to put the error code into errno on failure.  And of
course zero return value is not a failure.  There is not much that can
go wrong there.


More information about the Libc-help mailing list