Skip to content

Conversation

@mattsu2020
Copy link
Contributor

@mattsu2020 mattsu2020 commented Dec 29, 2025

Introduce a new write_stdout_line function that locks stdout and returns a Result to handle write failures gracefully. Replace all println! calls in verbose output, debug messages, and path printing with this function, propagating errors via CopyResult<()> instead of panicking on I/O errors. This improves reliability when stdout is closed or encounters issues during cp operations.

related
misc/close-stdout.sh

…r handling

Introduce a new `write_stdout_line` function that locks stdout and returns a Result to handle write failures gracefully. Replace all `println!` calls in verbose output, debug messages, and path printing with this function, propagating errors via `CopyResult<()>` instead of panicking on I/O errors. This improves reliability when stdout is closed or encounters issues during cp operations.
@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/id/smack was skipped on 'main' but is now failing.
Note: The gnu test tests/mkdir/smack-no-root was skipped on 'main' but is now failing.
Note: The gnu test tests/mkdir/smack-root was skipped on 'main' but is now failing.

…justing exit code

- Made `code` mutable to allow modification on flush errors.
- Ignore BrokenPipe errors during stdout flush to avoid breaking utilities that silence it (e.g., seq).
- Set exit code to 1 if a flush error occurs and the original code was 0, treating write errors as failures.
@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/basenc/bounded-memory is now being skipped but was previously passing.

- Added check to capture if stdout was closed before utility execution using fcntl on Unix.
- Modified flush error handling to ignore EBADF errors when stdout was pre-closed, avoiding false failures for silent commands.
@mattsu2020 mattsu2020 marked this pull request as draft December 29, 2025 04:59
Reorder imports for consistency and refactor the ignore_closed_stdout condition to a more concise form, improving code readability without altering functionality.
Add `stdout_is_closed()` and `is_closed_stdout_error()` functions to check if stdout is closed and detect write errors due to closed stdout. Refactor the `bin!` macro to use these functions, reducing code duplication and improving reusability across utilities.
@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/id/smack was skipped on 'main' but is now failing.
Note: The gnu test tests/mkdir/smack-no-root was skipped on 'main' but is now failing.
Note: The gnu test tests/mkdir/smack-root was skipped on 'main' but is now failing.

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