Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

IO.sysopen

IO.sysopen(path, mode = 'r', perm = 0666) → integer

Opens the file at the given path with the given mode and permissions; returns the integer file descriptor.

If the file is to be readable, it must exist; if the file is to be writable and does not exist, it is created with the given permissions:

Example
File.write('t.tmp', '')  # => 0
IO.sysopen('t.tmp')      # => 8
IO.sysopen('t.tmp', 'w') # => 9
See also .select .try_convert .readlines .write also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0