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

Extend checks for fsync in File.open with block #2293

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

herwinw
Copy link
Member

@herwinw herwinw commented Nov 6, 2024

fsync(2) fails with EINVAL for special file descriptors like blockdevs or sockets. Skip the fsync step on these objects. Simplify the check for socket, the respond_to?(:setsockopt) feels like a hack.

Easiest way to trigger an exception with the old code:

File.open('/dev/urandom') {}

fsync(2) fails with EINVAL for special file descriptors like blockdevs or
sockets. Skip the fsync step on these objects. Simplify the check for socket,
the `respond_to?(:setsockopt)` feels like a hack.

Easiest way to trigger an exception with the old code:

    File.open('/dev/urandom') {}
@seven1m seven1m merged commit fff8412 into natalie-lang:master Nov 6, 2024
15 checks passed
@herwinw herwinw deleted the file_open_block branch November 6, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants