Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h gr33n7007h/fd.rb Secret
Created Sep 29, 2019

Embed
What would you like to do?
>> require 'fcntl'
=> true
>>
>> f = File.open('/dev/urandom')
=> #<File:/dev/urandom>
>>
>> f.fcntl Fcntl::F_GETFL, 0
=> 32768
>>
>> f.read_nonblock 2
=> "\x88\x83"
>>
>> f.fcntl Fcntl::F_GETFL, 0
=> 34816
>>
>> 34816 - 32768 # 2048 = 04000 = non blocking flag
=> 2048
>>
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.