# Ctrl+C is SIGINT

> The terminal sends SIGINT on Ctrl+C; default handling terminates the process unless you catch the signal.

Source: https://fullbytedeveloper.com/blog/ctrl-c-is-sigint
Published here: 2026-12-03, updated 2026-12-03

Ctrl+C is not magic: the terminal delivers `SIGINT`, which is the interrupt-from-keyboard signal named in Linux signal(7) [1]. The default disposition is to terminate the running foreground process [1]. Related reads: [what happens when you press Enter](/blog/what-happens-when-you-press-enter) and [threads vs processes](/blog/threads-vs-processes).

## Quick start (under a minute)

List signal names on Linux:

```bash
kill -l | grep SIGINT
```

You should see `SIGINT` beside number 2. That number is what Python and C headers use when they say `signal.SIGINT` or `SIGINT`.

## Read the signal table row from the man page

Linux `signal(7)` [1]:

| Signal | Meaning | Default |
|---|---|---|
| `SIGINT` | Interrupt from keyboard | Term |
| `SIGTERM` | Termination signal | Term |
| `SIGKILL` | Kill (cannot be caught) | Term |

Other signals cover stop, continue, faults, and alarms. This page stays on the interactive interrupt path [1].

## Catch SIGINT in Python on this host

Python's `signal` module installs handlers for asynchronous events such as signals [2]. Minimal pattern:

```python
import signal
import sys
import time

def on_sigint(signum, frame):
    print("got SIGINT signum=%d" % signum, file=sys.stderr)
    sys.exit(130)

signal.signal(signal.SIGINT, on_sigint)
print("running; sending SIGINT next", flush=True)
while True:
    time.sleep(0.2)
```

Send `SIGINT` with `kill -INT <pid>` (same signal as Ctrl+C in a tty) [1].

Observed on this draft host (Python 3.12.3, Linux, 2026-12-03):

```text
running; sending SIGINT next
got SIGINT signum=2
```

Shell reported exit status 130 after that run, matching the 128+2 convention many shells use for signal deaths [3]. Without a handler, the default terminate path ends the process without your cleanup [1].

Exit code 130 is a teaching convention, not a POSIX law. Bash documents exit statuses for pipelines and signals separately; script authors should test on their target shell [3].

## Place Ctrl+C in the terminal pipeline

Pressing Enter submits a line to the shell, which may `exec` a child ([what happens when you press Enter](/blog/what-happens-when-you-press-enter)). While that child is in the foreground process group, Ctrl+C goes to the child as `SIGINT`, not to the shell's prompt loop [1].

Multi-threaded programs still receive signals at the process level. Which thread runs the handler is platform and runtime specific. Read [threads vs processes](/blog/threads-vs-processes) before claiming each thread gets its own Ctrl+C.

<figure aria-label="Ctrl+C to SIGINT on the foreground process">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 200" role="img" aria-hidden="true">
  <defs>
    <marker id="ctrlcissigint-sig-arr" markerWidth="8" markerHeight="8" refX="7" refY="4" orient="auto">
      <path d="M0,0 L8,4 L0,8 Z" fill="#14b8a6"/>
    </marker>
  </defs>
  <rect x="0" y="0" width="360" height="200" rx="12" fill="#0b1f3a"/>
  <rect x="15.4286" y="65" width="64.2857" height="70" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="0.964286"/>
  <text x="47.5714" y="96" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">Ctrl+C</text>
  <text x="47.5714" y="114" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">keyboard [1]</text>
  <rect x="102.857" y="45" width="77.1429" height="110" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="1.28571"/>
  <text x="141.429" y="88" text-anchor="middle" font-size="12" font-weight="600" fill="#e6edf7" font-family="system-ui,sans-serif">tty driver</text>
  <text x="141.429" y="106" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">maps to SIGINT [1]</text>
  <rect x="205.714" y="42" width="90" height="60" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="0.964286"/>
  <text x="250.714" y="70" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">foreground group</text>
  <text x="250.714" y="86" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">default: Term [1]</text>
  <rect x="205.714" y="103" width="90" height="50" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="0.964286"/>
  <text x="250.714" y="132" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">your handler [2]</text>
  <rect x="308.571" y="75" width="43.7143" height="50" rx="4" fill="#123052" stroke="#14b8a6" stroke-width="0.964286"/>
  <text x="330.429" y="104" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">shell</text>
  <line x1="79.7143" y1="100" x2="101.571" y2="100" stroke="#14b8a6" stroke-width="0.964286" marker-end="url(#ctrlcissigint-sig-arr)"/>
  <line x1="180" y1="100" x2="204.429" y2="72" stroke="#14b8a6" stroke-width="0.964286" marker-end="url(#ctrlcissigint-sig-arr)"/>
  <line x1="180" y1="100" x2="204.429" y2="128" stroke="#14b8a6" stroke-width="0.964286" marker-end="url(#ctrlcissigint-sig-arr)"/>
  <text x="180" y="182" text-anchor="middle" font-size="12" fill="#e6edf7" font-family="system-ui,sans-serif">SIGINT is process-wide; threads share one handler table [1]</text>
</svg>
</figure>

The shell survives because it is not the foreground job unless you interrupted an empty line at prompt (behavior can vary slightly by shell settings).

## Do not confuse SIGINT with kill -9

`kill -15` or `kill <pid>` sends `SIGTERM`, a polite shutdown request many daemons catch to flush logs [1]. `kill -9` sends `SIGKILL`, which cannot be caught or ignored [1]. Operators call that a hard kill.

Ctrl+C is `SIGINT`, softer than `SIGKILL`, sharper than ignoring the program. Teach teammates to prefer handlers that flush work then exit, instead of spreading the myth that Ctrl+C "force quits the terminal."

## Job control and who is in the foreground

Bash job control tracks foreground and background process groups [3]. When you run `./long_task`, that child is foreground until it exits. Ctrl+C delivers SIGINT to that group. When you background a job with `&` or `bg`, it is no longer foreground; Ctrl+C at the prompt may generate a new line instead of interrupting the background job. Use `fg` to bring it forward if you need to interrupt it interactively.

`stty` settings can remap keys, but the default on Linux ttys maps interrupt to Ctrl+C. GUI terminals emulate the same behavior by sending the interrupt character to the pty master.

## What happens if you catch SIGINT but never exit

A handler that only prints a message and returns leaves the process running [2]. That surprises users who expect Ctrl+C to stop a runaway loop. Document "press Ctrl+C twice" only if you implement it deliberately. Long-running data tools often catch once for graceful shutdown, then reset to default on a second interrupt.

`SIGKILL` remains the backstop when a process ignores SIGINT and SIGTERM [1]. Orchestrators use staged signals: TERM first, KILL after a timeout. Ctrl+C is not in that path unless a human is at the keyboard.

## Interrupt during blocking system calls

If your process is blocked in certain syscalls (read, write, connect), Linux may restart the syscall after a handled SIGINT or return `EINTR` depending on flags [1]. Python's signal docs note that not all C extension modules restart cleanly [2]. That is why some CLIs set a flag in the handler and check it after I/O returns instead of calling `sys.exit` inside the handler itself.

## Ctrl+C in pipelines

In a shell pipeline `cmd1 | cmd2`, signal delivery follows shell rules: Ctrl+C may terminate the whole pipeline or only the foreground stage depending on shell options (`set -m`, bash `set -o pipefail`, etc.) [3]. If `cmd1` buffers and `cmd2` is slow, interrupting may leave a zombie stage. For teaching, run the simple single-process demo above before debugging pipelines.

## Pty versus raw SSH without tty

`ssh host command` without a pseudo-terminal may not map your local Ctrl+C to the remote process the way an interactive session does. `ssh -t` allocates a tty when you need interrupt semantics. Containers started without `-it` behave similarly: signals reach PID 1 rulesets, not always your app.

## Signal masks in worker threads

POSIX threads can block signals with `pthread_sigmask` while the main thread handles them [1]. Python documents that signal handlers should be registered on the main thread [2]. Worker pools that swallow interrupts can leave the parent process running after Ctrl+C appears to do nothing. When that happens, check which thread owns the handler before blaming the terminal.

## Common mistakes and misconceptions

Thinking Ctrl+C kills the terminal app. It signals the foreground process. Your shell session stays open.

Expecting SIGINT during `docker run` attach or `ssh` remote sessions exactly like local tty. PTY forwarding and job control change who is foreground. When in doubt, use `kill -INT <pid>` on the known child.

Every language exposes the same handler rules. Python documents main-thread handler registration limits [2]. JVM and Go have their own notes. Read the platform page before shipping a CLI.

Using Ctrl+C during `git rebase` or editors without reading the key binding. Some tools map Ctrl+C to cancel input, not POSIX SIGINT to child. Context matters.

Exit code 130 always means SIGINT. Scripts can exit 130 manually, as the demo does with `sys.exit(130)` [2]. Combine exit codes with logs, not superstition.

Try the handler sketch on a throwaway script, then run a long job and note whether exit code 130 shows up in your shell. When a pipeline misbehaves, compare foreground groups with the Enter and exec story in [what happens when you press Enter](/blog/what-happens-when-you-press-enter). For threaded tools where only one thread may register handlers, pair this page with [threads vs processes](/blog/threads-vs-processes) before you blame the keyboard.

Send this to the friend who mashes Ctrl+C and thinks the shell itself died.

Image: Teal and orange arrows from stacked slabs through a glowing concentric-ring sphere into transparent cubes with tiny linked nodes beside a teal-outlined black cube, no people.
https://fullbytedeveloper.com/media/ctrl-c-is-sigint/ctrl-c-is-sigint-venice.webp
Ctrl+C maps to SIGINT for the foreground job, not the whole terminal session.

## Sources

1. [Linux man-pages: signal(7), accessed 2026-12-03](https://man7.org/linux/man-pages/man7/signal.7.html)
2. [Python docs: signal, accessed 2026-12-03](https://docs.python.org/3/library/signal.html)
3. [GNU Bash manual: Exit Status, accessed 2026-12-03](https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html)
4. [Full Byte Developer: What happens when you press Enter](https://fullbytedeveloper.com/blog/what-happens-when-you-press-enter)
5. [Full Byte Developer: Threads vs processes](https://fullbytedeveloper.com/blog/threads-vs-processes)
