Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h

gr33n7007h/fd.rb Secret

Created September 29, 2019 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gr33n7007h/4eb5ce9f635648ef4ba1e3e9c665ac76 to your computer and use it in GitHub Desktop.
Save gr33n7007h/4eb5ce9f635648ef4ba1e3e9c665ac76 to your computer and use it in GitHub Desktop.
>> 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