Possible infinite loop on pipe_drain()
In src/common/compat_threads.c
, there is this function:
static int
pipe_drain(int fd)
{
char buf[32];
ssize_t r;
while ((r = read_ni(fd, buf, sizeof(buf))) >= 0)
;
if (r == 0 || errno != EAGAIN)
return -1;
return 0;
}
This one will end up in an infinite loop because read() returns 0 when EOF. Furthermore, if let say we get out of this loop somehow, errno == SUCCESS will return -1. Even if the fd is in non blocking mode, if the fd is drained, the last read() will return 0 non stop (I tested it here with two threads).
I'm coming up with a fix asap that use a safer read() wrapper.