mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +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
Notes:
sideshowbarker
2024-07-18 03:41:13 +09:00
Author: https://github.com/seiferteric 🔰 Commit: https://github.com/SerenityOS/serenity/commit/edbc5489a88 Pull-request: https://github.com/SerenityOS/serenity/pull/10135
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);
|
||||
if (fds().open_count() + 2 > fds().max_open())
|
||||
return EMFILE;
|
||||
// Reject flags other than O_CLOEXEC.
|
||||
if ((flags & O_CLOEXEC) != flags)
|
||||
// Reject flags other than O_CLOEXEC, O_NONBLOCK
|
||||
if ((flags & (O_CLOEXEC | O_NONBLOCK)) != flags)
|
||||
return EINVAL;
|
||||
|
||||
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);
|
||||
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[writer_fd_allocation.fd].set(move(writer_description), fd_flags);
|
||||
|
|
Loading…
Reference in a new issue