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

Use file handles directly instead of C file descriptors on Win32 #14501

Merged

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Apr 16, 2024

Resolves #14389.

This makes IO::FileDescriptor#@volatile_fd an Atomic(LibC::UIntPtrT) rather than an Atomic(LibC::HANDLE), to avoid breaking #fd's return type.

Comment on lines +87 to +89
ORIGINAL_STDIN = IO::FileDescriptor.new(Crystal::System::FileDescriptor::STDIN_HANDLE, blocking: true)
ORIGINAL_STDOUT = IO::FileDescriptor.new(Crystal::System::FileDescriptor::STDOUT_HANDLE, blocking: true)
ORIGINAL_STDERR = IO::FileDescriptor.new(Crystal::System::FileDescriptor::STDERR_HANDLE, blocking: true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be shortened to:

Suggested change
ORIGINAL_STDIN = IO::FileDescriptor.new(Crystal::System::FileDescriptor::STDIN_HANDLE, blocking: true)
ORIGINAL_STDOUT = IO::FileDescriptor.new(Crystal::System::FileDescriptor::STDOUT_HANDLE, blocking: true)
ORIGINAL_STDERR = IO::FileDescriptor.new(Crystal::System::FileDescriptor::STDERR_HANDLE, blocking: true)
ORIGINAL_STDIN = IO::FileDescriptor.new(FileDescriptor::STDIN_HANDLE, blocking: true)
ORIGINAL_STDOUT = IO::FileDescriptor.new(FileDescriptor::STDOUT_HANDLE, blocking: true)
ORIGINAL_STDERR = IO::FileDescriptor.new(FileDescriptor::STDERR_HANDLE, blocking: true)

@HertzDevil
Copy link
Contributor Author

Note to self: lib/reply/src/term_size.cr also defines LibC::STD_OUTPUT_HANDLE which should be dropped after this PR (this doesn't show up on CI because the interpreter is still disabled)

@straight-shoota straight-shoota added this to the 1.13.0 milestone Apr 19, 2024
@straight-shoota straight-shoota merged commit 096f89b into crystal-lang:master Apr 21, 2024
60 checks passed
@HertzDevil HertzDevil deleted the refactor/win32-file-handle branch April 21, 2024 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Introduce platform-specific FileDescriptor::Handle
3 participants