summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/pipe.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Syscalls/pipe.cpp')
-rw-r--r--Kernel/Syscalls/pipe.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/Kernel/Syscalls/pipe.cpp b/Kernel/Syscalls/pipe.cpp
index 3d82917c8f..5692f2f139 100644
--- a/Kernel/Syscalls/pipe.cpp
+++ b/Kernel/Syscalls/pipe.cpp
@@ -42,14 +42,21 @@ int Process::sys$pipe(int pipefd[2], int flags)
u32 fd_flags = (flags & O_CLOEXEC) ? FD_CLOEXEC : 0;
auto fifo = FIFO::create(m_uid);
+ auto open_reader_result = fifo->open_direction(FIFO::Direction::Reader);
+ if (open_reader_result.is_error())
+ return open_reader_result.error();
+ auto open_writer_result = fifo->open_direction(FIFO::Direction::Writer);
+ if (open_writer_result.is_error())
+ return open_writer_result.error();
+
int reader_fd = alloc_fd();
- m_fds[reader_fd].set(fifo->open_direction(FIFO::Direction::Reader), fd_flags);
+ m_fds[reader_fd].set(open_reader_result.release_value(), fd_flags);
m_fds[reader_fd].description()->set_readable(true);
if (!copy_to_user(&pipefd[0], &reader_fd))
return -EFAULT;
int writer_fd = alloc_fd();
- m_fds[writer_fd].set(fifo->open_direction(FIFO::Direction::Writer), fd_flags);
+ m_fds[writer_fd].set(open_writer_result.release_value(), fd_flags);
m_fds[writer_fd].description()->set_writable(true);
if (!copy_to_user(&pipefd[1], &writer_fd))
return -EFAULT;