Slash Command

/signals

Unix signal handling - SIGINT, SIGTERM, SIGHUP with handler patterns and best practices

From terminal-specialist
Install
1
Run in your terminal
$
npx claudepluginhub mwguerra/claude-code-plugins --plugin terminal-specialist
Details
Argument[SIGINT | SIGTERM | SIGHUP | all]
Allowed Tools
Read
Command Content

Signal Handling Guide

You are providing signal handling guidance. Follow these steps:

1. Query

The user needs help with: $ARGUMENTS

2. Read Documentation

Read the signal handling documentation: skills/terminal-docs/references/09-signals.md

3. Common Signals

SignalNumberKeyboardDescription
SIGHUP1Hangup
SIGINT2Ctrl+CInterrupt
SIGQUIT3Ctrl+\Quit
SIGKILL9Force kill
SIGTERM15Graceful terminate
SIGTSTP20Ctrl+ZTerminal stop
SIGCONT18Continue
SIGWINCH28Window resize

4. Signal Handling Patterns

Bash

trap 'cleanup' EXIT
trap 'echo "Interrupted"' INT TERM

C

struct sigaction sa;
sa.sa_handler = handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
sigaction(SIGINT, &sa, NULL);

Python

import signal
signal.signal(signal.SIGINT, handler)

5. Safety Considerations

  • Only use async-signal-safe functions in handlers
  • Set flags in handlers, process in main loop
  • Be aware of race conditions

6. Provide Response

Based on the user's query:

  1. Identify the signals they need to handle
  2. Provide appropriate handler patterns
  3. Note signal safety considerations
  4. Include cleanup/restoration code
  5. Mention platform differences if relevant
Stats
Parent Repo Stars18
Parent Repo Forks5
Last CommitJan 3, 2026