pipe: add support for non-blocking operation
This is needed by Redis (ticket
@@ -122,6 +122,10 @@ static sysreturn pipe_read_bh(pipe_file pf, thread t, void *dest, u64 length,
if (real_length == 0) {
if (pf->pipe->files[PIPE_WRITE].fd == -1)
goto out;
+ if (pf->f.flags & O_NONBLOCK) {
+ real_length = -EAGAIN;
+ goto out;
+ }
return infinity;
}
@@ -171,6 +175,10 @@ static sysreturn pipe_write_bh(pipe_file pf, thread t, void *dest, u64 length,
rv = -EPIPE;
goto out;
}
+ if (pf->f.flags & O_NONBLOCK) {
+ rv = -EAGAIN;
+ goto out;
+ }
return infinity;
}
