Skip to content

Conversation

@mattsu2020
Copy link
Contributor

@mattsu2020 mattsu2020 commented Nov 4, 2025

Add a new function ensure_stdin_open() that uses the nix crate to check if stdin is open before attempting to read from it. This prevents potential errors when stdin is closed, improving robustness of the tac command on Unix systems. Updated dependencies to include nix in Cargo.toml and Cargo.lock.

relate
#9127

Add a new function `ensure_stdin_open()` that uses the `nix` crate to check if stdin is open before attempting to read from it. This prevents potential errors when stdin is closed, improving robustness of the tac command on Unix systems. Updated dependencies to include `nix` in Cargo.toml and Cargo.lock.
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 4, 2025

CodSpeed Performance Report

Merging #9137 will not alter performance

Comparing mattsu2020:tac_compatibility (c768673) with main (06d843f)

Summary

✅ 127 untouched
⏩ 6 skipped1

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link

github-actions bot commented Nov 4, 2025

GNU testsuite comparison:

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

@sylvestre
Copy link
Contributor

the test doesn't seem to pass ?!

@sylvestre
Copy link
Contributor


2025-11-04T04:38:10.6776687Z FAIL: tests/tac/tac-2-nonseekable
2025-11-04T04:38:10.6776753Z =================================
2025-11-04T04:38:10.6776756Z 
2025-11-04T04:38:10.6776872Z FAIL tests/tac/tac-2-nonseekable.sh (exit status: 1)

- Call path.metadata() once instead of multiple times to improve performance
- Check if path is a directory or file using the single metadata result
- Add test for FIFO (named pipe) input to ensure proper handling of non-regular files
- This change reduces redundant system calls and enables tac to work with FIFOs by falling back to read() when not a regular file
- Remove unnecessary line breaks in OpenOptions and child.wait() calls for conciseness and readability.
Replace match statement with if-let-else for path.metadata() to leverage modern Rust syntax, improving code conciseness without altering functionality.
…rectly

Zero-length files in procfs/sysfs may still produce data, but memory mapping them yields an empty buffer, causing incorrect behavior. This change adds a check for file length > 0 before attempting mmap, ensuring compatibility with GNU tac-2-nonseekable test.
Add "sysfs" to the cspell jargon dictionary to prevent spell check warnings for this Linux filesystem term used in the codebase.
@github-actions
Copy link

github-actions bot commented Nov 8, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

- Switch tac crate dependency from nix to libc
- Implement direct libc-based checks for stdin state and /dev/null
- Avoids nix dependency while preserving robust stdin error handling
- Replace CStr::from_bytes_with_nul with CString::new for /dev/null to simplify construction and clarify intent
- Remove unused libc import, keeping unix-specific code minimal and cleaner
- Add ACCMODE, RDONLY, RDWR to cspell jargon dictionary to avoid false positives
- Gate CString and MaybeUninit imports behind unix cfg to prevent non-unix build issues
@github-actions
Copy link

github-actions bot commented Nov 8, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/tac/tac-2-nonseekable is no longer failing!

- Add nix as a unix-only dependency for tac
- Replace direct libc fcntl/open/fstat calls with nix equivalents
- Simplify stdin/dev-null checks for improved safety and clarity
- Remove libc dependency from tac crate and Cargo.lock
- Use nix OFlag/FileStat and std::os::fd::AsRawFd for stdin checks
- Improve error handling by mapping nix Errno to std::io::Error
- Reorders nix::fcntl imports to follow a consistent, conventional order
- Improves code readability without changing behavior
@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/tac/tac-2-nonseekable is no longer failing!

@mattsu2020 mattsu2020 requested a review from sylvestre November 12, 2025 23:37
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/tac/tac-2-nonseekable is no longer failing!

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/tac/tac-2-nonseekable is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tac/tac-2-nonseekable is no longer failing!

@ChrisDryden
Copy link
Collaborator

Does this make it change compatibility for when the input is /dev/null ?

- Simplify stdin closure check by removing /dev/null specific logic
- Remove unused functions and imports
- Add test ensuring RDWR /dev/null stdin is supported
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

…tion

Remove dependency on nix crate and use uucore's new signals feature to detect
if stdin was closed before Rust reopens it as /dev/null. This centralizes stdio
state handling and improves consistency across utilities. Add libc dependency
for signal functions. Update error handling to set exit code properly on
stdin closure.
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@mattsu2020 mattsu2020 marked this pull request as draft December 16, 2025 07:35
@mattsu2020 mattsu2020 closed this Dec 25, 2025
@mattsu2020 mattsu2020 deleted the tac_compatibility branch December 25, 2025 10:31
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.

3 participants