What are common trap signals?

QuestionsQuestions8 SkillsProBash Trap CommandNov, 29 2025
093

Common signals that can be caught using the trap command in Bash include:

  1. SIGINT (2): Triggered by pressing Ctrl+C; used to interrupt a running process.
  2. SIGTERM (15): The default termination signal; used to request a process to terminate.
  3. SIGHUP (1): Sent when the terminal is closed; often used to indicate that a session has ended.
  4. SIGQUIT (3): Triggered by pressing Ctrl+; used to quit a process and generate a core dump.
  5. SIGKILL (9): Cannot be caught or ignored; used to forcefully terminate a process.
  6. SIGUSR1 and SIGUSR2 (10 and 12): User-defined signals that can be used for custom purposes.
  7. SIGALRM (14): Sent when a timer set by the alarm command expires.

You can specify these signals in the trap command to define custom actions when they are received.

0 Comments

no data
Be the first to share your comment!