Commit 290741e
authored
feat: Add --batch option for single Ctrl+C termination (pdsh -b compatibility) (#102)
* feat: Add --batch option for single Ctrl+C termination (pdsh -b compatibility)
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
* fix: Address PR #102 review issues for signal handling
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
* fix: Add signal handling to file transfer and file output mode operations
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.1 parent 55fd38d commit 290741e
File tree
7 files changed
+560
-20
lines changed- src
- app
- commands
- executor
- ui/tui
7 files changed
+560
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
303 | 396 | | |
304 | 397 | | |
305 | 398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
333 | 359 | | |
334 | 360 | | |
335 | 361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
| 406 | + | |
406 | 407 | | |
407 | 408 | | |
408 | 409 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
107 | 114 | | |
108 | 115 | | |
109 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
| 178 | + | |
177 | 179 | | |
178 | 180 | | |
179 | 181 | | |
| |||
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
212 | | - | |
| 214 | + | |
| 215 | + | |
213 | 216 | | |
214 | 217 | | |
215 | 218 | | |
| |||
0 commit comments