summaryrefslogtreecommitdiff
path: root/code/snippets/multiple_filenos.rb
blob: aca4caf8feb9e4bf12b133751604b32e555e958b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
passwd = File.open('/etc/passwd')
puts passwd.fileno

hosts = File.open('/etc/hosts')
puts hosts.fileno

# Close the open passwd file. The frees up its file descriptor
# number to be used by the next opened resource.
passwd.close

null = File.open('/dev/null')
puts null.fileno