mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
unix: Fix handling of EAGAIN in sp_nonblocking_write().
This commit is contained in:
parent
81243567bc
commit
55ab7e0b6b
@ -952,10 +952,15 @@ SP_API enum sp_return sp_nonblocking_write(struct sp_port *port,
|
|||||||
/* Returns the number of bytes written, or -1 upon failure. */
|
/* Returns the number of bytes written, or -1 upon failure. */
|
||||||
ssize_t written = write(port->fd, buf, count);
|
ssize_t written = write(port->fd, buf, count);
|
||||||
|
|
||||||
if (written < 0)
|
if (written < 0) {
|
||||||
RETURN_FAIL("write() failed");
|
if (errno == EAGAIN)
|
||||||
|
// Buffer is full, no bytes written.
|
||||||
|
RETURN_INT(0);
|
||||||
else
|
else
|
||||||
|
RETURN_FAIL("write() failed");
|
||||||
|
} else {
|
||||||
RETURN_INT(written);
|
RETURN_INT(written);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user