* read() from removed usb-serial device
@ 2020-07-07 14:49 Frank Schäfer
2020-07-07 15:16 ` Johan Hovold
2020-07-07 15:19 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Frank Schäfer @ 2020-07-07 14:49 UTC (permalink / raw)
To: Johan Hovold; +Cc: linux-usb@vger.kernel.org
Hi,
I recently noticed that read() from a usb-serial device does not fail
after the device got removed.
Is this really the correct/expected behavior or a bug ?
I would expect it to return -1 and set an appropriate errno, but it
returns 0 (no error, no bytes read) instead.
According to the glibc developers "glibc just calls into the kernel and
reports back whatever it receives from there."
Regards,
Frank
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: read() from removed usb-serial device
2020-07-07 14:49 read() from removed usb-serial device Frank Schäfer
@ 2020-07-07 15:16 ` Johan Hovold
2020-07-07 15:19 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2020-07-07 15:16 UTC (permalink / raw)
To: Frank Schäfer; +Cc: Johan Hovold, linux-usb@vger.kernel.org
On Tue, Jul 07, 2020 at 04:49:31PM +0200, Frank Schäfer wrote:
> Hi,
>
> I recently noticed that read() from a usb-serial device does not fail
> after the device got removed.
> Is this really the correct/expected behavior or a bug ?
>
> I would expect it to return -1 and set an appropriate errno, but it
> returns 0 (no error, no bytes read) instead.
>
> According to the glibc developers "glibc just calls into the kernel and
> reports back whatever it receives from there."
Yeah, this is the expected behaviour for a hung up tty (see poll(2) or
the POSIX spec).
Johan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: read() from removed usb-serial device
2020-07-07 14:49 read() from removed usb-serial device Frank Schäfer
2020-07-07 15:16 ` Johan Hovold
@ 2020-07-07 15:19 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2020-07-07 15:19 UTC (permalink / raw)
To: Frank Schäfer; +Cc: Johan Hovold, linux-usb@vger.kernel.org
On Tue, Jul 07, 2020 at 04:49:31PM +0200, Frank Schäfer wrote:
> Hi,
>
> I recently noticed that read() from a usb-serial device does not fail after
> the device got removed.
> Is this really the correct/expected behavior or a bug ?
You application did not get the hangup event and stop reading?
> I would expect it to return -1 and set an appropriate errno, but it returns
> 0 (no error, no bytes read) instead.
0 is correct here, why would there be an error? There's no data for you
to read from a device that is gone :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-07 15:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-07 14:49 read() from removed usb-serial device Frank Schäfer
2020-07-07 15:16 ` Johan Hovold
2020-07-07 15:19 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).