mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 07:37:34 +00:00
Kernel: Add support for O_NONBLOCK in pipe syscall
While working on a port, I saw a pipe creation fail due to missing nonblock support in pipe syscall.
This commit is contained in:
parent
2e079c6d69
commit
edbc5489a8
1 changed files with 6 additions and 2 deletions
|
@ -15,8 +15,8 @@ KResultOr<FlatPtr> Process::sys$pipe(int pipefd[2], int flags)
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(stdio);
|
||||||
if (fds().open_count() + 2 > fds().max_open())
|
if (fds().open_count() + 2 > fds().max_open())
|
||||||
return EMFILE;
|
return EMFILE;
|
||||||
// Reject flags other than O_CLOEXEC.
|
// Reject flags other than O_CLOEXEC, O_NONBLOCK
|
||||||
if ((flags & O_CLOEXEC) != flags)
|
if ((flags & (O_CLOEXEC | O_NONBLOCK)) != flags)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
u32 fd_flags = (flags & O_CLOEXEC) ? FD_CLOEXEC : 0;
|
u32 fd_flags = (flags & O_CLOEXEC) ? FD_CLOEXEC : 0;
|
||||||
|
@ -30,6 +30,10 @@ KResultOr<FlatPtr> Process::sys$pipe(int pipefd[2], int flags)
|
||||||
|
|
||||||
reader_description->set_readable(true);
|
reader_description->set_readable(true);
|
||||||
writer_description->set_writable(true);
|
writer_description->set_writable(true);
|
||||||
|
if (flags & O_NONBLOCK) {
|
||||||
|
reader_description->set_blocking(false);
|
||||||
|
writer_description->set_blocking(false);
|
||||||
|
}
|
||||||
|
|
||||||
m_fds[reader_fd_allocation.fd].set(move(reader_description), fd_flags);
|
m_fds[reader_fd_allocation.fd].set(move(reader_description), fd_flags);
|
||||||
m_fds[writer_fd_allocation.fd].set(move(writer_description), fd_flags);
|
m_fds[writer_fd_allocation.fd].set(move(writer_description), fd_flags);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue