]> git.tdb.fi Git - libs/core.git/commitdiff
Check for closed handles when changing Pipe flags
authorMikko Rasa <tdb@tdb.fi>
Sun, 31 Oct 2021 13:12:26 +0000 (15:12 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 31 Oct 2021 18:30:30 +0000 (20:30 +0200)
source/io/pipe.cpp

index 01bf20aaea32c056b33e2213dafdd1d0515c3f1e..f6bc335d4216a48e820f9bd98c10c1e9b8c761f3 100644 (file)
@@ -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)