mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-20 01:52:49 +08:00
Allow for EWOULDBLOCK instead of EAGAIN
Posix allows this as an alternative with the same semantics for read. Found in conjunction with #9067. Should be no functional difference on other systems.
This commit is contained in:
parent
df5489e0a4
commit
a98301b021
|
@ -175,7 +175,7 @@ bool fd_event_signaller_t::try_consume() const {
|
|||
do {
|
||||
ret = read(read_fd(), buff, sizeof buff);
|
||||
} while (ret < 0 && errno == EINTR);
|
||||
if (ret < 0 && errno != EAGAIN) {
|
||||
if (ret < 0 && errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||
wperror(L"read");
|
||||
}
|
||||
return ret > 0;
|
||||
|
@ -193,7 +193,7 @@ void fd_event_signaller_t::post() {
|
|||
ret = write(write_fd(), &c, sizeof c);
|
||||
} while (ret < 0 && errno == EINTR);
|
||||
// EAGAIN occurs if either the pipe buffer is full or the eventfd overflows (very unlikely).
|
||||
if (ret < 0 && errno != EAGAIN) {
|
||||
if (ret < 0 && errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||
wperror(L"write");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ ssize_t io_buffer_t::read_once(int fd, acquired_lock<separated_buffer_t> &buffer
|
|||
do {
|
||||
amt = read(fd, bytes, sizeof bytes);
|
||||
} while (amt < 0 && errno == EINTR);
|
||||
if (amt < 0 && errno != EAGAIN) {
|
||||
if (amt < 0 && errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||
wperror(L"read");
|
||||
} else if (amt > 0) {
|
||||
buffer->append(bytes, static_cast<size_t>(amt));
|
||||
|
@ -116,7 +116,7 @@ void io_buffer_t::begin_filling(autoclose_fd_t fd) {
|
|||
// select() reported us as readable; read a bit.
|
||||
auto buffer = buffer_.acquire();
|
||||
ssize_t ret = read_once(fd.fd(), buffer);
|
||||
done = (ret == 0 || (ret < 0 && errno != EAGAIN));
|
||||
done = (ret == 0 || (ret < 0 && errno != EAGAIN && errno != EWOULDBLOCK));
|
||||
} else if (shutdown_fillthread_) {
|
||||
// Here our caller asked us to shut down; read while we keep getting data.
|
||||
// This will stop when the fd is closed or if we get EAGAIN.
|
||||
|
|
|
@ -96,7 +96,7 @@ void binary_semaphore_t::wait() {
|
|||
auto amt = read(fd, &ignored, sizeof ignored);
|
||||
if (amt == 1) break;
|
||||
// EAGAIN should only be returned in TSan case.
|
||||
if (amt < 0 && errno != EINTR && errno != EAGAIN) die(L"read");
|
||||
if (amt < 0 && errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) die(L"read");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user