Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h

gr33n7007h/fd.rb Secret

Created September 29, 2019 16:31
>> 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