From 47f7e3590f7e7cb1bec9ba9873ba1a0ee76cf0cc Mon Sep 17 00:00:00 2001 From: Wesley Moxam Date: Sat, 18 Nov 2017 12:53:27 -0500 Subject: [PATCH] Fixes setting IO blocking on OpenBSD (#5283) --- src/io/file_descriptor.cr | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/io/file_descriptor.cr b/src/io/file_descriptor.cr index 5ffcf75e3cd8..4250ccc69ed5 100644 --- a/src/io/file_descriptor.cr +++ b/src/io/file_descriptor.cr @@ -22,13 +22,14 @@ class IO::FileDescriptor < IO end def blocking=(value) - flags = fcntl(LibC::F_GETFL) + current_flags = fcntl(LibC::F_GETFL) + new_flags = current_flags if value - flags &= ~LibC::O_NONBLOCK + new_flags &= ~LibC::O_NONBLOCK else - flags |= LibC::O_NONBLOCK + new_flags |= LibC::O_NONBLOCK end - fcntl(LibC::F_SETFL, flags) + fcntl(LibC::F_SETFL, new_flags) unless new_flags == current_flags end def close_on_exec?