Skip to content

Commit

Permalink
Fix Crystal::System::FileDescriptor to use @fd ivar directly (crystal…
Browse files Browse the repository at this point in the history
…-lang#6703)

* Fix Crystal::System::FileDescriptor to use @fd ivar directly

* fixup! Fix Crystal::System::FileDescriptor to use @fd ivar directly
  • Loading branch information
straight-shoota authored and Ezra Stevens committed Oct 1, 2018
1 parent d806ff8 commit 6ba3440
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/crystal/system/unix/file_descriptor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ module Crystal::System::FileDescriptor
end

private def system_tty?
LibC.isatty(fd) == 1
LibC.isatty(@fd) == 1
end

private def system_reopen(other : IO::FileDescriptor)
{% if LibC.methods.includes? "dup3".id %}
# dup doesn't copy the CLOEXEC flag, so copy it manually using dup3
flags = other.close_on_exec? ? LibC::O_CLOEXEC : 0
if LibC.dup3(other.fd, self.fd, flags) == -1
if LibC.dup3(other.@fd, @fd, flags) == -1
raise Errno.new("Could not reopen file descriptor")
end
{% else %}
# dup doesn't copy the CLOEXEC flag, copy it manually to the new
if LibC.dup2(other.fd, self.fd) == -1
if LibC.dup2(other.@fd, @fd) == -1
raise Errno.new("Could not reopen file descriptor")
end

Expand Down

0 comments on commit 6ba3440

Please sign in to comment.