Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Crystal::System::FileDescriptor to use @fd ivar directly #6703

Merged

Conversation

straight-shoota
Copy link
Member

A method fd is actually not exposed in Crystal::System::FileDescriptor itself, so accessing the ivar directly is better and consistent with the rest of the module (everywhere else in this file it's @fd).

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might drop the self.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, it looks weird.

@RX14 RX14 added this to the 0.27.0 milestone Sep 12, 2018
@RX14 RX14 merged commit 74fe37c into crystal-lang:master Sep 12, 2018
@straight-shoota straight-shoota deleted the jm/fix/filedescriptor-use-ivar branch September 12, 2018 16:39
ezrast pushed a commit to ezrast/crystal that referenced this pull request Oct 2, 2018
…-lang#6703)

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

* fixup! Fix Crystal::System::FileDescriptor to use @fd ivar directly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants