Skip to content

Conversation

@ChrisDryden
Copy link
Collaborator

@ChrisDryden ChrisDryden commented Jan 10, 2026

There's a bunch of deviation from our implementation of Yes and Timeout and the gnu version and a long time ago, the gnu tests were patched so that for some tests it used the system yes and timeout. Now that we have proper signal handling implementations for our utilities we can revert this change and also see the gaps in our yes and timeout implementation and the gnu implementation by removing the overrides.

One key area that this will fail is the env-signal-handler test. It was relying on a bunch on non-implemented functionality in timeout that we need to implement for this test to pass. Mainly related to the non standard posix signals like RTMAX/RTMIN which is described here: #6218

UPDATE:
There are still issues with our implementation of timeout, so even though this brings us closer to the GNU implementation, its still not enough to remove the GNU patch. Will handle that in a later PR once timeout is in a better state.

@ChrisDryden
Copy link
Collaborator Author

Somehow every SELinux test failed here

@ChrisDryden
Copy link
Collaborator Author

I think I might take the approach of splitting this to first deploy the timeout and yes fixes and then make the change to revert the overrides.

@ChrisDryden
Copy link
Collaborator Author

I'm discovering how much the timeout utility has changed between now and the launch of 9.9, its quite different when it comes to signal handling

@ChrisDryden ChrisDryden changed the title yes, timeout: removing gnu timeout and yes overrides and adding pipeline signal handlers yes, timeout: adding pipeline signal handlers Jan 11, 2026
@ChrisDryden ChrisDryden marked this pull request as ready for review January 11, 2026 23:54
@ChrisDryden
Copy link
Collaborator Author

Getting this working is going to be a very complex issue when it comes to ordering the PR's. I have a working branch that implements timeout in the same way that the latest master in coreutils works, but its involves quite a bunch of changes so I'm hoping to get this one in before I make that PR.

@github-actions
Copy link

GNU testsuite comparison:

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

if uucore::signals::sigpipe_was_ignored() {
uucore::show_error!(
"{}",
translate!("yes-error-standard-output", "error" => err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, we should use "err.kind()" instead of "err" in order to match exactly GNU yes error string and remove the "os error 32":

asteba@asteba-MS-7C75:~/dev/coreutils$ trap '' PIPE
asteba@asteba-MS-7C75:~/dev/coreutils$ ./target/debug/coreutils yes | head -1
y
yes: standard output: Broken pipe (os error 32)
asteba@asteba-MS-7C75:~/dev/coreutils$ /usr/bin/gnuyes | head -1
y
gnuyes: standard output: Broken pipe


/// Configures a Command to preserve SIGPIPE disposition for child processes.
/// When the parent had SIGPIPE ignored, this ensures the child also has it ignored.
#[cfg(unix)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining that Rust's stdlib resets SIGPIPE to SIG_DFL when spawning child processes (Rust source: https://github.com/rust-lang/rust/blob/fe98ddcfcfb6f185dbf4adeaf439d8a756da0273/library/std/src/sys/process/unix/unix.rs#L742 ), unless the -Zon-broken-pipe flag is used. This breaks Unix signal inheritance when the parent has SIGPIPE ignored, which is why preserve_sigpipe_for_child() uses pre_exec() to restore the ignored state before exec.

It is critical context that the rust stdlib restores SIGPIPE to SIG_DFL when calling Command functions. Without this context, I'm concerned that future readers would not understand the role of preserve_sigpipe_for_child().

#[test]
#[cfg(unix)]
#[cfg(feature = "yes")]
fn test_sigpipe_ignored_preserves_for_child() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn test_sigpipe_ignored_preserves_for_child() {
fn test_sigpipe_ignored_preserved_for_child() {

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