Skip to content

Conversation

@andreacorbellini
Copy link
Contributor

@andreacorbellini andreacorbellini commented Oct 30, 2025

If a read error happens after opening the file, that error is never reported and comm just quits without printing any error message. This commit fixes that.

This also removes the is_dir() check, preventing a potential race condition where the path could be swapped with a directory in between the is_dir() check and the open() call. On Unix, this correctly results in the "is a directory" error message to be printed (this is detected at read() time).

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 30, 2025

CodSpeed Performance Report

Merging #9086 will not alter performance

Comparing andreacorbellini:comm-safer-is_dir (6bc9f47) with main (8f7afa7)

Summary

✅ 125 untouched

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@andreacorbellini andreacorbellini changed the title comm: check if the input file is a directory after opening it comm: report all I/O errors Oct 31, 2025
I/O errors were being silently suppressed. This also removes an
unnecessary check to see if one of the inputs is a directory.
@andreacorbellini
Copy link
Contributor Author

For Windows I decided to stick with the same behavior of Unix: report the error from the operating system. In the case of Windows, if the file is a directory, you get "permission denied". Not very user friendly, but I think this is the best approach, mostly because it's not racy.

If the maintainers don't like that, we can add a metadata check just for Windows (not on Unix), maybe something like: try to open the file, if it fails with a "permission denied", check if it's a directory, and based on that report the most appropriate error message. Let me know what you prefer and I will update the PR accordingly.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

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.

1 participant