Index: sys/kern/sys_pipe.c =================================================================== RCS file: /cvsroot/src/sys/kern/sys_pipe.c,v retrieving revision 1.160 diff -p -u -r1.160 sys_pipe.c --- sys/kern/sys_pipe.c 22 Apr 2023 13:53:02 -0000 1.160 +++ sys/kern/sys_pipe.c 28 May 2023 05:40:17 -0000 @@ -850,7 +850,7 @@ pipe_poll(file_t *fp, int events) revents |= POLLHUP; if (revents == 0) { - if (events & (POLLIN | POLLRDNORM)) + if (events & (POLLIN | POLLHUP | POLLRDNORM)) selrecord(curlwp, &rpipe->pipe_sel); if (events & (POLLOUT | POLLWRNORM)) @@ -979,13 +979,16 @@ pipeclose(struct pipe *pipe) goto free_resources; mutex_enter(lock); - pipeselwakeup(pipe, pipe, POLL_HUP); /* - * If the other side is blocked, wake it up saying that - * we want to close it down. + * Tell everyone, we are closing down. */ pipe->pipe_state |= PIPE_EOF; + pipeselwakeup(pipe, pipe, POLL_HUP); + + /* + * Wake up blocked users. + */ if (pipe->pipe_busy) { while (pipe->pipe_busy) { cv_broadcast(&pipe->pipe_wcv); @@ -997,8 +1000,8 @@ pipeclose(struct pipe *pipe) * Disconnect from peer. */ if ((ppipe = pipe->pipe_peer) != NULL) { - pipeselwakeup(ppipe, ppipe, POLL_HUP); ppipe->pipe_state |= PIPE_EOF; + pipeselwakeup(ppipe, ppipe, POLL_HUP); cv_broadcast(&ppipe->pipe_rcv); ppipe->pipe_peer = NULL; }