Skip to content
Snippets Groups Projects
  • Nadav Har'El's avatar
    f6d134bc
    Change pipe event from POLLRDHUP to POLLERR|POLLOUT · f6d134bc
    Nadav Har'El authored
    
    We used to return the POLLRDHUP event when polling a write-side of a pipe
    whose reader is closed, but Linux returns POLLERR|POLLOUT, so let's do
    the same.
    
    Linux's behavior can be explained in that when the reader is closed, a write
    will return immediately (and hence POLLOUT) but moreover, will return with
    an error (EPIPE). And since a read will also cause an error (EBADF when
    reading on the write side of the pipe), a POLLERR makes sense and says
    that any operation on this fd will now result in an error.
    
    This patch also adds a test for this case.
    
    Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
    f6d134bc
    History
    Change pipe event from POLLRDHUP to POLLERR|POLLOUT
    Nadav Har'El authored
    
    We used to return the POLLRDHUP event when polling a write-side of a pipe
    whose reader is closed, but Linux returns POLLERR|POLLOUT, so let's do
    the same.
    
    Linux's behavior can be explained in that when the reader is closed, a write
    will return immediately (and hence POLLOUT) but moreover, will return with
    an error (EPIPE). And since a read will also cause an error (EBADF when
    reading on the write side of the pipe), a POLLERR makes sense and says
    that any operation on this fd will now result in an error.
    
    This patch also adds a test for this case.
    
    Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>