Skip to content

Conversation

@Ecordonnier
Copy link
Collaborator

@Ecordonnier Ecordonnier commented Nov 26, 2025

forking creates a new PID and it not compatible with GNU coreutils implementation.

  • use Command::exec() instead of Command::spawn() which forks
  • add stdbuf test verifying that no fork happens

Fixes #9066

@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)

@Ecordonnier

This comment was marked as resolved.

@oech3

This comment was marked as resolved.

@Ecordonnier Ecordonnier force-pushed the eco/stdbuf-exec-instead-of-fork branch from de2b66c to 0110357 Compare December 1, 2025 12:50
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

GNU testsuite comparison:

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

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 3, 2025

Merging this PR will not alter performance

✅ 141 untouched benchmarks
⏩ 38 skipped benchmarks1


Comparing Ecordonnier:eco/stdbuf-exec-instead-of-fork (548a5e9) with main (0d403a4)

Open in CodSpeed

Footnotes

  1. 38 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 Dec 3, 2025

GNU testsuite comparison:

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

@Ecordonnier Ecordonnier force-pushed the eco/stdbuf-exec-instead-of-fork branch from 0d7529b to 4c557bf Compare December 3, 2025 13:21
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

GNU testsuite comparison:

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

@Ecordonnier
Copy link
Collaborator Author

This is ready for review. I don't intend to work on this branch any more.

@Ecordonnier
Copy link
Collaborator Author

Ecordonnier commented Dec 9, 2025

I've just seen #9013 (comment) which is also relevant for my PR. I'll check if Command::exec() can be used instead of Command::status().

@Ecordonnier Ecordonnier force-pushed the eco/stdbuf-exec-instead-of-fork branch from 4c557bf to 9afe842 Compare December 9, 2025 10:27
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

GNU testsuite comparison:

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

@Ecordonnier Ecordonnier force-pushed the eco/stdbuf-exec-instead-of-fork branch from 9afe842 to af3957e Compare December 9, 2025 11:13
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

GNU testsuite comparison:

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

@Ecordonnier
Copy link
Collaborator Author

The PR is ready for review.

@Ecordonnier Ecordonnier force-pushed the eco/stdbuf-exec-instead-of-fork branch from af3957e to 197203c Compare December 9, 2025 20:54
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

GNU testsuite comparison:

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

@Ecordonnier Ecordonnier force-pushed the eco/stdbuf-exec-instead-of-fork branch from 197203c to 8ae82a8 Compare December 9, 2025 21:23
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

GNU testsuite comparison:

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

@Ecordonnier Ecordonnier force-pushed the eco/stdbuf-exec-instead-of-fork branch from 8ae82a8 to 11a9c80 Compare December 10, 2025 09:46
@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)

@Ecordonnier Ecordonnier force-pushed the eco/stdbuf-exec-instead-of-fork branch from 11a9c80 to 7963769 Compare December 17, 2025 09:35
@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/tail/inotify-dir-recreate is now passing!

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

GNU testsuite comparison:

GNU test failed: tests/shuf/shuf-reservoir. tests/shuf/shuf-reservoir is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?

Forking creates a new PID and it not compatible with GNU coreutils implementation.
- use exec instead of forking
- add test verifying that execvp is used

Fixes uutils#9066

Signed-off-by: Etienne Cordonnier <[email protected]>
@Ecordonnier Ecordonnier force-pushed the eco/stdbuf-exec-instead-of-fork branch from 964753c to a235f1a Compare January 6, 2026 21:24
@github-actions
Copy link

github-actions bot commented Jan 6, 2026

GNU testsuite comparison:

Congrats! The gnu test tests/shuf/shuf-reservoir is no longer failing!
Congrats! The gnu test tests/sort/sort-stale-thread-mem is no longer failing!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces the fork+spawn implementation in stdbuf with a direct exec() call, making it compatible with GNU coreutils. The previous implementation broke signal handling and PR_SET_PDEATHSIG because it created a new PID through forking. With exec(), the stdbuf process is replaced by the target command, preserving the PID and allowing signals to propagate correctly.

Changes:

  • Replaced Command::spawn() with Command::exec() to avoid forking
  • Simplified error handling by removing wait/signal logic (no longer needed with exec)
  • Added comprehensive test to verify no fork occurs by checking /proc cmdline

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/uu/stdbuf/src/stdbuf.rs Replaces spawn+wait with exec, updates imports, simplifies error handling to match exec-only flow
tests/by-util/test_stdbuf.rs Adds Linux-specific regression test that validates exec behavior by polling /proc to ensure process replacement occurs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Ecordonnier
Copy link
Collaborator Author

@cakebaker can you please review this PR?

@oech3

This comment was marked as resolved.

@sylvestre sylvestre merged commit c66be8c into uutils:main Jan 17, 2026
132 checks passed
@Ecordonnier Ecordonnier deleted the eco/stdbuf-exec-instead-of-fork branch January 17, 2026 09:32
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.

stdbuf implementation via spawning is incompatible with coreutils

3 participants