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: #file_descriptor_close should set @closed (UNIX) #14973

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/crystal/system/unix/file_descriptor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ module Crystal::System::FileDescriptor
end

def file_descriptor_close(&) : Nil
# It would usually be set by IO::Buffered#unbuffered_close but we sometimes
# close file descriptors directly (i.e. signal/process pipes) and the IO
# object wouldn't be marked as closed, leading IO::FileDescriptor#finalize
# to try to close the fd again (pointless) and lead to other issues if we
# try to do more cleanup in the finalizer (error)
@closed = true

# Clear the @volatile_fd before actually closing it in order to
# reduce the chance of reading an outdated fd value
_fd = @volatile_fd.swap(-1)
Expand Down
Loading