From 3c124305d7aabb282b8f74e00c58373a2ed77c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Thu, 9 Aug 2018 18:45:59 +0200 Subject: [PATCH 1/2] Fix Crystal::System::FileDescriptor to use @fd ivar directly --- src/crystal/system/unix/file_descriptor.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crystal/system/unix/file_descriptor.cr b/src/crystal/system/unix/file_descriptor.cr index 608b179252ff..fe7b4c4d74a0 100644 --- a/src/crystal/system/unix/file_descriptor.cr +++ b/src/crystal/system/unix/file_descriptor.cr @@ -81,19 +81,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, self.@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, self.@fd) == -1 raise Errno.new("Could not reopen file descriptor") end From 44552d5279c0b8118e5310d58799a9ab6c284861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Wed, 12 Sep 2018 11:09:49 +0200 Subject: [PATCH 2/2] fixup! Fix Crystal::System::FileDescriptor to use @fd ivar directly --- src/crystal/system/unix/file_descriptor.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crystal/system/unix/file_descriptor.cr b/src/crystal/system/unix/file_descriptor.cr index fe7b4c4d74a0..c9cf8e20035a 100644 --- a/src/crystal/system/unix/file_descriptor.cr +++ b/src/crystal/system/unix/file_descriptor.cr @@ -88,12 +88,12 @@ module Crystal::System::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