This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit d5d4059a6cb39597340154ab13d83c9f4f9f64ea Author: Marco Casaroli <[email protected]> AuthorDate: Mon Nov 16 08:10:39 2026 +0100 fs/vfs/fs_poll.c: Keep POLLOUT when POLLERR is set. poll_notify() cleared POLLOUT whenever POLLERR or POLLHUP was set. POSIX makes only POLLHUP and POLLOUT mutually exclusive; POLLERR may come with POLLOUT. Linux reports both for the write end of a pipe without readers, where write() fails with EPIPE at once. The pipe driver sets POLLOUT and POLLERR for that pipe, but poll_notify() removed the POLLOUT, so a writer that waits for POLLOUT (with epoll, or poll() with only POLLOUT) got POLLERR alone. Clear POLLOUT only for POLLHUP. The pipe driver's comment says what it does now: POLLERR with POLLOUT when the pipe has no readers. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- drivers/pipes/pipe_common.c | 4 +++- fs/vfs/fs_poll.c | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/pipes/pipe_common.c b/drivers/pipes/pipe_common.c index 08d89aca912..ea9b3debea0 100644 --- a/drivers/pipes/pipe_common.c +++ b/drivers/pipes/pipe_common.c @@ -979,7 +979,9 @@ int pipecommon_poll(FAR struct file *filep, FAR struct pollfd_s *fds, eventset |= POLLHUP; } - /* Change POLLOUT to POLLERR, if no readers and policy 0. */ + /* POLLERR with POLLOUT, if no readers and policy 0 (write() gives + * EPIPE at once, as on Linux). + */ if ((eventset & POLLOUT) && PIPE_IS_POLICY_0(dev->d_flags) && diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c index df6f96b6ab7..eefe6c6d737 100644 --- a/fs/vfs/fs_poll.c +++ b/fs/vfs/fs_poll.c @@ -290,10 +290,13 @@ void poll_notify(FAR struct pollfd_s **afds, int nfds, pollevent_t eventset) fds->revents |= eventset & (fds->events | POLLERR | POLLHUP) & ~POLLALWAYS; - if ((fds->revents & (POLLERR | POLLHUP)) != 0) - { - /* Error or Hung up, clear POLLOUT event */ + /* POLLHUP and POLLOUT are mutually exclusive (POSIX). POLLERR + * may come with POLLOUT, as on Linux. + */ + + if ((fds->revents & POLLHUP) != 0) + { fds->revents &= ~POLLOUT; }
