From 26a5878092f6547e701fd1a33abbf1878d26ab70 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 31 Oct 2021 15:12:26 +0200 Subject: [PATCH] Check for closed handles when changing Pipe flags --- source/io/pipe.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/io/pipe.cpp b/source/io/pipe.cpp index 01bf20a..f6bc335 100644 --- a/source/io/pipe.cpp +++ b/source/io/pipe.cpp @@ -43,15 +43,19 @@ void Pipe::set_mode(Mode m) void Pipe::set_block(bool b) { adjust_mode(mode, M_NONBLOCK, !b); - sys_set_blocking(read_handle, b); - sys_set_blocking(write_handle, b); + if(read_handle) + sys_set_blocking(read_handle, b); + if(write_handle) + sys_set_blocking(write_handle, b); } void Pipe::set_inherit(bool i) { adjust_mode(mode, M_INHERIT, i); - sys_set_inherit(read_handle, i); - sys_set_inherit(write_handle, i); + if(read_handle) + sys_set_inherit(read_handle, i); + if(write_handle) + sys_set_inherit(write_handle, i); } size_t Pipe::do_write(const char *buf, size_t size) -- 2.45.2