Feature Request: Escape/Cancel Hook for Process Cleanup

Resolved 💬 3 comments Opened Jul 29, 2025 by un33k Closed Jan 4, 2026

Feature Request: Escape/Cancel Hook for Process Cleanup

Problem: When running scripts that spawn background processes, pressing Escape terminates the parent script but leaves child processes running without cleanup.

Example Scenario:

  1. foo.sh launches a remote process and waits for response
  2. User presses Escape to cancel
  3. foo.sh terminates immediately
  4. Remote process continues running (no cleanup signal sent)

Proposed Solution: Add a cancellation hook that triggers when Escape is pressed, allowing scripts to:

  • Send termination signals to child processes
  • Close network connections
  • Clean up temporary resources
  • Gracefully shut down before exiting

Implementation: Could be exposed as:

  • Signal handler for SIGINT/SIGTERM
  • Explicit cancel callback registration
  • "onCancel" hook in the script lifecycle

This would ensure proper cleanup when users interrupt long-running operations.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗