Re: Blocking read() from a USB->Serial adapter.



On 2006-11-27, jasen <jasen@xxxxxxxxxxx> wrote:

Or until the driver decides to return for whatever reason it
chooses. On success, you're guaranteed a minimum of one byte.

Maybe. (Maybe not too!)

There's the case where the file is at EOF. Is there another
case where read() will return success with 0 bytes?

AIUI EOF is not success.

Yes it is. EOF returns 0. Any value other than -1 is defined
as "success". Most people assume any negative value indicates
an error.

Fromm the read(2) man page:

RETURN VALUE

On success, the number of bytes read is returned (zero
indicates end of file). [...] On error, -1 is returned,
and errno is set appropriately.

a break symbol (or framing error etc...) on the seriai line
will also cause read to return.

Intesting -- I didn't know that either.

--
Grant Edwards grante Yow! Quick, sing me the
at BUDAPEST NATIONAL ANTHEM!!
visi.com
.



Relevant Pages

  • Re: Blocking read() from a USB->Serial adapter.
    ... On success, you're guaranteed a minimum of one byte. ... There's the case where the file is at EOF. ... The tty line discipline will generate an "EOF" ... simulate it, not an EOF condition. ...
    (comp.os.linux.development.apps)
  • Re: Blocking read() from a USB->Serial adapter.
    ... On success, you're guaranteed a minimum of one byte. ... There's the case where the file is at EOF. ... condition and return 0 bytes when it sees the EOF character ... (typically ctrl-d) ...
    (comp.os.linux.development.apps)
  • Re: which functions set the end-of-file indicator?
    ... everyone agreed that it's possible for EOF to be a valid byte. ... It is, however, trivial to convert EOF into an unsigned char. ... As they take an int expression for their first arguments, ... s) == SUCCESS) return ch; ...
    (comp.lang.c)
  • Re: which functions set the end-of-file indicator?
    ... everyone agreed that it's possible for EOF to be a valid byte. ... It is, however, trivial to convert EOF into an unsigned char. ... As they take an int expression for their first arguments, ... s) == SUCCESS) return ch; ...
    (comp.lang.c)
  • Re: returning error from main()
    ... EXIT_SUCCESS to denote success. ... If a function fails and sets errno, ... use perroror strerrorto construct an error message (but you may ... and non zero for failure. ...
    (comp.lang.c)