From 7ff509608321d0bd47d7ceebbf68e8732955a29f Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 23 Sep 2023 12:57:03 +0200 Subject: [PATCH] kernel: Avoid page faults when reading from a slave pseudoterminal after the master is destroyed --- kernel/src/fs/devices/SlavePTY.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/src/fs/devices/SlavePTY.cpp b/kernel/src/fs/devices/SlavePTY.cpp index 93d32d5e..91fd333a 100644 --- a/kernel/src/fs/devices/SlavePTY.cpp +++ b/kernel/src/fs/devices/SlavePTY.cpp @@ -36,6 +36,8 @@ Result SlavePTY::write(const u8* buf, usize, usize length) bool SlavePTY::will_block_if_read() const { + if (!m_master) return false; + if (!m_master->is_canonical()) return m_buffer.is_empty(); else return !m_master->m_lines.size();