From: Mikko Rasa Date: Sun, 31 Oct 2021 13:12:26 +0000 (+0200) Subject: Check for closed handles when changing Pipe flags X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=26a5878092f6547e701fd1a33abbf1878d26ab70;p=libs%2Fcore.git Check for closed handles when changing Pipe flags --- 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)