Repository navigation
Revert foreground process changes to fix MacOS piping bug (less and fzf) - #6542
Merged
Merged
Conversation
…running external command (nushell#6273)" This reverts commit 1d18f69.
Contributor
|
thanks |
This was referenced Sep 11, 2022
valpackett
added a commit
to valpackett/nushell
that referenced
this pull request
Sep 19, 2022
…s while running external command (nushell#6273)" (nushell#6542)" This reverts commit 2bb367f.
valpackett
added a commit
to valpackett/nushell
that referenced
this pull request
Sep 19, 2022
…s while running external command (nushell#6273)" (nushell#6542)" This reverts commit 2bb367f.
6 tasks
valpackett
added a commit
to valpackett/nushell
that referenced
this pull request
Sep 20, 2022
…s while running external command (nushell#6273)" (nushell#6542)" This reverts commit 2bb367f.
fdncred
added a commit
that referenced
this pull request
Sep 29, 2022
* Revert "Revert "Try again: in unix like system, set foreground process while running external command (#6273)" (#6542)" This reverts commit 2bb367f. * Make foreground job control hopefully work correctly These changes are mostly inspired by the glibc manual. * Fix typo in external command description * Only restore tty control to shell when no fg procs are left; reuse pgrp * Rework terminal acquirement code to be like fish Co-authored-by: Darren Schroeder <[email protected]>
fdncred
pushed a commit
that referenced
this pull request
Nov 23, 2026
## Description Adds a regression test for pipeline signal handling: pressing Ctrl+C while a pipeline of two external commands is running should interrupt both of them, and Nushell should carry on with the rest of the script. The test starts `nu -i` on its own pseudo-terminal, so the externals run in a foreground process group the way they would in a real terminal. Both commands trap SIGINT and print a line when they get it. After Ctrl+C the test expects `producer`, `consumer`, and then `resumed` from the next statement. Output is read through a separate socket, so terminal echo can't make the test pass by accident. To check that it catches the kind of bug described in #6542, I changed `set_foreground_pid` in `crates/nu-system/src/foreground.rs` so that every external in a pipeline got its own process group. With that change the test fails after its 15 second read timeout. With the current code it passes. I haven't tried it against the older commits mentioned in the issue. The test is Unix only (`#[cfg(unix)]`) because it relies on a pty and process groups. ## User-facing changes (Release notes) n/a ## Additional notes Part of #6591. This covers Ctrl+C in a two-command external pipeline. Other cases from #6542 could follow in separate PRs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6534 #6516 #6496. This PR reverts #6273.
The history is:
In unix like system, set foreground process while running external command #6206 made the name of the running process be correctly advertised to tmux/terminal emulators, as was requested by some users.
However, this caused some crashes: Shell gets suspended #6240, so it was reverted in Fix intermittent test crash #6268.
Try again: in unix like system, set foreground process while running external command #6273 fixed the crashes. However it causes a hang on some systems (mostly MacOS) when piping into
lessandfzf, (and other programs that uselessas their pager such asgit,bat, anddelta). See Nushell can't handle well with less command on MacOS #6496It seems to make sense to revert again, since the broken piping is worse than the lack of terminal titles. Note that the released version 0.68.1 has the MacOS piping bug.
Tests
I've tested on MacOS that
yes | head -n 999 | fzfandyes | head -n 999 | lesshang onmainbut succeed as expected on this branch.There wasn't much conflict when making this revert: the diff is the reverse of the original. But if anyone knows of PRs that have merged in the interim and don't make sense with this revert, they should shout out. To check the revert diff I looked at:
It's a difficult area to test and there aren't really tests yet.
Try to think about corner cases and various ways how your changes could break. Cover them with tests.
If adding tests is not possible, please document in the PR body a minimal example with steps on how to reproduce so one can verify your change works.
cargo fmt --all -- --checkto check standard code formatting (cargo fmt --allapplies these changes)cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectto check that you're using the standard code stylecargo test --workspace --features=extrato check that all the tests pass