feat: Add --batch option for single Ctrl+C termination (pdsh -b compatibility)#102
Merged
feat: Add --batch option for single Ctrl+C termination (pdsh -b compatibility)#102
Conversation
inureyes
added a commit
that referenced
this pull request
Dec 16, 2025
This commit fixes all HIGH and MEDIUM severity issues identified in PR #102 review: HIGH SEVERITY FIXES: 1. Signal Handler Race Condition - Time Window Reset Logic Bug - Fixed: When time window expires (>1 second) and user presses Ctrl+C again, the code now displays running/completed status in the reset path - Location: src/executor/parallel.rs lines 701-713 (stream mode) - Impact: Consistent user experience across all Ctrl+C press scenarios 2. Inconsistent Signal Handling Across Execution Modes - Fixed: Added complete signal handling to normal execute() method - Previously only handle_stream_mode() had signal handling - Location: src/executor/parallel.rs lines 172-280 (execute method) - Impact: Batch mode and two-stage Ctrl+C now work in all execution modes MEDIUM SEVERITY FIXES: 3. Missing Exit Code Handling After Signal Termination - Fixed: All signal terminations now exit with code 130 (SIGINT standard) - Applied to both batch and non-batch modes in all execution paths - Location: Multiple locations in src/executor/parallel.rs - Impact: Scripts can now distinguish user interruption from command failure 4. No Documentation Conflict Warning for TUI Mode - Fixed: Updated CLI help text to clarify TUI mode ignores batch flag - Location: src/cli.rs line 103 - Impact: Clear user expectations for TUI mode behavior 5. Documentation Mismatch in ARCHITECTURE.md - Fixed: Updated pseudocode and documentation to match actual implementation - Added exit code handling details and implementation coverage notes - Location: ARCHITECTURE.md lines 303-394 - Impact: Accurate documentation for future maintainers TESTING: - All tests pass (cargo test) - No clippy warnings (cargo clippy -- -D warnings) - Code properly formatted (cargo fmt --check) Changes: - ARCHITECTURE.md: Updated signal handling documentation with accurate pseudocode - src/cli.rs: Added TUI mode note to batch flag help text - src/executor/parallel.rs: Added signal handling to execute(), fixed reset path status display, added exit code 130
inureyes
added a commit
that referenced
this pull request
Dec 16, 2025
…ions This commit adds proper Ctrl+C signal handling to all file transfer methods and the file output mode handler: - upload_file: Added tokio::select! with two-stage Ctrl+C handling - download_file: Added tokio::select! with two-stage Ctrl+C handling - download_files: Added tokio::select! with two-stage Ctrl+C handling - handle_file_mode: Refactored from simple while loop to tokio::select! pattern All methods now support: - Batch mode: Single Ctrl+C immediately terminates with exit code 130 - Non-batch mode: First Ctrl+C shows status, second terminates - Proper abort of pending task handles on termination - Status reporting showing running/completed task counts These changes complete the signal handling improvements from PR #102, ensuring all parallel execution paths can be gracefully interrupted.
…tibility) Add --batch / -b option that changes Ctrl+C behavior to immediately terminate all parallel jobs with a single press. This improves automation and CI/CD integration by providing immediate termination without requiring confirmation. Changes: - Add --batch / -b CLI flag to Cli struct - Pass batch flag through ExecuteCommandParams to ParallelExecutor - Implement two-stage Ctrl+C handling in stream mode: * Default: First Ctrl+C shows status, second terminates (within 1s) * Batch mode: Single Ctrl+C immediately terminates all jobs - Update TUI mode signature to accept batch parameter (reserved for future use) - Add CLI help examples for batch mode usage - Update README.md with Batch Mode section and examples - Document signal handling implementation in ARCHITECTURE.md The default behavior provides visibility into execution progress before termination, while batch mode is optimized for scripts and non-interactive environments. Implements: #95
This commit fixes all HIGH and MEDIUM severity issues identified in PR #102 review: HIGH SEVERITY FIXES: 1. Signal Handler Race Condition - Time Window Reset Logic Bug - Fixed: When time window expires (>1 second) and user presses Ctrl+C again, the code now displays running/completed status in the reset path - Location: src/executor/parallel.rs lines 701-713 (stream mode) - Impact: Consistent user experience across all Ctrl+C press scenarios 2. Inconsistent Signal Handling Across Execution Modes - Fixed: Added complete signal handling to normal execute() method - Previously only handle_stream_mode() had signal handling - Location: src/executor/parallel.rs lines 172-280 (execute method) - Impact: Batch mode and two-stage Ctrl+C now work in all execution modes MEDIUM SEVERITY FIXES: 3. Missing Exit Code Handling After Signal Termination - Fixed: All signal terminations now exit with code 130 (SIGINT standard) - Applied to both batch and non-batch modes in all execution paths - Location: Multiple locations in src/executor/parallel.rs - Impact: Scripts can now distinguish user interruption from command failure 4. No Documentation Conflict Warning for TUI Mode - Fixed: Updated CLI help text to clarify TUI mode ignores batch flag - Location: src/cli.rs line 103 - Impact: Clear user expectations for TUI mode behavior 5. Documentation Mismatch in ARCHITECTURE.md - Fixed: Updated pseudocode and documentation to match actual implementation - Added exit code handling details and implementation coverage notes - Location: ARCHITECTURE.md lines 303-394 - Impact: Accurate documentation for future maintainers TESTING: - All tests pass (cargo test) - No clippy warnings (cargo clippy -- -D warnings) - Code properly formatted (cargo fmt --check) Changes: - ARCHITECTURE.md: Updated signal handling documentation with accurate pseudocode - src/cli.rs: Added TUI mode note to batch flag help text - src/executor/parallel.rs: Added signal handling to execute(), fixed reset path status display, added exit code 130
…ions This commit adds proper Ctrl+C signal handling to all file transfer methods and the file output mode handler: - upload_file: Added tokio::select! with two-stage Ctrl+C handling - download_file: Added tokio::select! with two-stage Ctrl+C handling - download_files: Added tokio::select! with two-stage Ctrl+C handling - handle_file_mode: Refactored from simple while loop to tokio::select! pattern All methods now support: - Batch mode: Single Ctrl+C immediately terminates with exit code 130 - Non-batch mode: First Ctrl+C shows status, second terminates - Proper abort of pending task handles on termination - Status reporting showing running/completed task counts These changes complete the signal handling improvements from PR #102, ensuring all parallel execution paths can be gracefully interrupted.
06b7115 to
c0fe704
Compare
This was referenced Dec 17, 2025
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.
Summary
Implements
--batch/-boption that changes Ctrl+C behavior to immediately terminate all parallel jobs with a single press. This improves automation and CI/CD integration by providing immediate termination without requiring confirmation.Changes
Core Implementation
src/cli.rs): Added--batch/-bflag with help textsrc/app/dispatcher.rs,src/commands/exec.rs): Pass batch flag through ExecuteCommandParams to ParallelExecutorsrc/executor/parallel.rs):src/ui/tui/mod.rs): Updated signature to accept batch parameter (reserved for future use)Documentation
Behavior
Default Mode (Two-Stage Ctrl+C)
Batch Mode (Immediate Termination)
Compatibility
This feature provides pdsh
-bcompatibility, making it easier for users migrating from pdsh to bssh.Testing
Test Plan
Manual testing should verify:
Closes #95