Repository navigation
Add a test for Ctrl+C in a pipeline of external commands - #19641
Conversation
There was a problem hiding this comment.
Review overview
🟡 Changes recommended
The pty setup works on macOS once one cast is added, and the test then passed 20 of 20 runs. As pushed, though, it doesn't compile there, and because every root integration test builds into the same tests target, none of them compile on a Mac either. The other two findings are small changes to the assertion and the failure message.
Findings: 0
Open (3)
Notes from my clanker, checked on 80d51b0. Built the branch on macOS, where the root tests target fails to compile (E0308 on TIOCSCTTY). With as _ added, cargo test --test tests -- shell::pipeline::foreground passed 20 of 20 runs and clippy with CI's flags was clean, both before and after adding the two test suggestions below. Nothing ran on Linux. The Linux side comes from reading libc and a clippy check of the ioctl line for x86_64-unknown-linux-gnu.
|
Thanks, applied all three in e7f9983: the |
|
Thanks |



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 -ion 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 expectsproducer,consumer, and thenresumedfrom 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_pidincrates/nu-system/src/foreground.rsso 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.