Problem / Background
By default, pdsh (and potentially bssh) uses a two-stage Ctrl+C handling:
- First Ctrl+C: Shows status of running threads
- Second Ctrl+C (within 1 second): Terminates all jobs
The -b (batch) option in pdsh disables this feature, making a single Ctrl+C immediately terminate all parallel jobs. This is useful for:
- Non-interactive scripts
- CI/CD pipelines
- Situations where immediate termination is preferred
This is part of the pdsh compatibility initiative (Phase 1: New Options for Feature Parity).
Parent Issue
Part of #91 (pdsh compatibility mode) - Phase 1: New Options for Feature Parity
Proposed Solution
Add a --batch / -b option that changes Ctrl+C behavior to immediately terminate all parallel jobs with a single press.
CLI Interface
# Default behavior (two-stage Ctrl+C)
bssh -H "node1,node2,node3" "long-running-command"
# Ctrl+C shows status, second Ctrl+C terminates
# Batch mode (single Ctrl+C terminates)
bssh -H "node1,node2,node3" --batch "long-running-command"
# Ctrl+C immediately terminates all jobs
Option Definition
#[arg(
short = 'b',
long = "batch",
help = "Batch mode: single Ctrl+C immediately terminates all jobs\nDisables status display on first Ctrl+C"
)]
pub batch: bool,
Acceptance Criteria
Technical Considerations
- Current bssh signal handling needs to be reviewed (see
src/executor.rs)
- May need to implement the two-stage Ctrl+C first if not already present
- Consider using tokio's signal handling with
tokio::signal::ctrl_c()
- Need to ensure all SSH connections are properly closed on termination
- The
-b short option does not conflict with existing bssh options
Implementation Tasks
- Add the
--batch flag to Cli struct in src/cli.rs
- Review and document current Ctrl+C handling behavior
- Implement batch mode signal handling:
- If
--batch: Single Ctrl+C triggers immediate termination
- If not
--batch: First Ctrl+C shows status, second terminates
- Pass the batch flag through to executor
- Update all output modes (TUI, stream, normal) to respect batch mode
- Write tests for signal handling scenarios
- Update CLI help and README examples
Notes
- Short option
-b does not conflict with existing bssh options
- This feature improves automation and scripting capabilities
- Implementation should maintain backward compatibility (default behavior unchanged)
Problem / Background
By default, pdsh (and potentially bssh) uses a two-stage Ctrl+C handling:
The
-b(batch) option in pdsh disables this feature, making a single Ctrl+C immediately terminate all parallel jobs. This is useful for:This is part of the pdsh compatibility initiative (Phase 1: New Options for Feature Parity).
Parent Issue
Part of #91 (pdsh compatibility mode) - Phase 1: New Options for Feature Parity
Proposed Solution
Add a
--batch/-boption that changes Ctrl+C behavior to immediately terminate all parallel jobs with a single press.CLI Interface
Option Definition
Acceptance Criteria
--batch/-boption toClistruct insrc/cli.rsTechnical Considerations
src/executor.rs)tokio::signal::ctrl_c()-bshort option does not conflict with existing bssh optionsImplementation Tasks
--batchflag toClistruct insrc/cli.rs--batch: Single Ctrl+C triggers immediate termination--batch: First Ctrl+C shows status, second terminatesNotes
-bdoes not conflict with existing bssh options