Skip to content

Commit

Permalink
Fixes setting IO blocking on OpenBSD (#5283)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wesley Moxam authored and RX14 committed Nov 18, 2017
1 parent 7f276fd commit 47f7e35
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/io/file_descriptor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 47f7e35

Please sign in to comment.