diff -up fs/pipe.c.pipe_fd_sigio_poll_hup fs/pipe.c --- fs/pipe.c.pipe_fd_sigio_poll_hup 2022-08-31 16:18:21.000000000 +0100 +++ fs/pipe.c 2022-09-07 14:03:00.438030398 +0100 @@ -383,7 +383,11 @@ pipe_read(struct kiocb *iocb, struct iov wake_next_reader = true; } if (pipe_empty(pipe->head, pipe->tail)) + { wake_next_reader = false; + if ( pipe->fasync_readers && !pipe->writers ) + kill_fasync(&pipe->fasync_readers, SIGIO, POLL_HUP); + } __pipe_unlock(pipe); if (was_full) @@ -592,7 +596,13 @@ out: */ if (was_empty || pipe->poll_usage) wake_up_interruptible_sync_poll(&pipe->rd_wait, EPOLLIN | EPOLLRDNORM); - kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); + + if ( (ret > 0) && pipe->fasync_readers && !pipe_empty(pipe->head, pipe->tail) ) + kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); + else + if ( !pipe->writers ) + kill_fasync(&pipe->fasync_readers, SIGIO, POLL_HUP); + if (wake_next_writer) wake_up_interruptible_sync_poll(&pipe->wr_wait, EPOLLOUT | EPOLLWRNORM); if (ret > 0 && sb_start_write_trylock(file_inode(filp)->i_sb)) {