Stopping Processes

Full control over your processes with the complete signal hierarchy, from gentle interrupts to immediate termination.

Stopping Methods

Command Book provides multiple ways to stop processes, from graceful shutdown to immediate termination.

Graceful Stop (SIGTERM)

Keyboard: ⌘. Sidebar: Click the stop button

Sends SIGTERM to the process, allowing it to:

  • Clean up temporary files
  • Close database connections
  • Finish pending operations
  • Save state if needed

Most well-written applications handle SIGTERM gracefully.

Force Stop (SIGKILL)

Keyboard: ⌘⇧. Sidebar: Hold Option and click stop

Sends SIGKILL to the process. This:

  • Terminates immediately
  • Cannot be caught or ignored
  • May leave resources uncleaned

Use kill only when a process doesn't respond to graceful stop requests (SIGTERM).

Interrupt (SIGINT)

Keyboard: Ctrl+C (when output pane is focused)

Sends SIGINT, equivalent to pressing Ctrl+C in a terminal. This:

  • Is the most common way to stop interactive programs
  • Can be caught by the application
  • Often triggers graceful shutdown

EOF Signal (SIGHUP)

Keyboard: Ctrl+D (when output pane is focused)

Sends SIGHUP, equivalent to pressing Ctrl+D. Useful for:

  • Signaling end of input
  • Programs waiting for stdin

Restart

Keyboard: ⌘R

Restart sends SIGTERM to stop the process, waits for it to gracefully terminate, then starts it again with the same command and configuration. It's equivalent to Stop followed by Start.

Signal Hierarchy

When stopping a process, Command Book follows this sequence for graceful termination:

  1. SIGINT → Wait for response
  2. SIGTERM → Wait 3 seconds
  3. SIGKILL → Immediate termination

You can skip directly to any level using the keyboard shortcuts.

Batch Operations

Stop All Processes

Stop all running processes at once:

  1. Use the menu: Commands → Stop All
  2. Or use the keyboard shortcut

All processes receive SIGTERM simultaneously.

Exiting Command Book with running processes will trigger a call to stop all processes and then exit. This is why exiting with running processes may take a moment. You can toggle a confirmation dialog to warn on exit in the settings.

Restart All Processes

Restart everything:

  1. Use the menu: Commands → Restart All
  2. Processes stop gracefully, then restart

Auto-Restart Behavior

When a process with auto-restart enabled is stopped:

  • Manual stop: Auto-restart is cancelled
  • Crash/unexpected exit: Auto-restart triggers after the configured delay
  • Restart command: Process stops and restarts immediately

The sidebar shows a countdown when auto-restart is pending.

Exit Codes

When a process stops, Command Book displays the exit code:

Exit Code Meaning
0 Success (normal exit)
1 General error
2 Misuse of command
126 Permission problem
127 Command not found
128+N Terminated by signal N
130 Interrupted (Ctrl+C)
137 Killed (SIGKILL)
143 Terminated (SIGTERM)

Quitting Command Book

When you quit Command Book with running processes:

  1. A confirmation dialog appears listing running processes (if enabled in Settings)
  2. Clicking "Quit" sends SIGTERM to all processes
  3. Processes have 10 seconds to exit gracefully
  4. Any remaining processes are force-killed with SIGKILL

This ensures well-behaved processes have the opportunity to close database connections, flush open files, and perform other cleanup.

Disable the confirmation in Settings → General → "Warn when quitting with running processes".

Note: You can close the window and Command Book continues running in the Dock. Your processes keep running and output keeps capturing. Click the Dock icon to bring the window back.

Best Practices

  1. Try graceful first: Always try ⌘. before force-stopping
  2. Check for hung processes: If SIGTERM doesn't work within a few seconds, use SIGKILL
  3. Use Ctrl+C for interactive apps: Many tools expect interrupt signals
  4. Configure auto-restart carefully: Only enable for processes that should always run