Why Ctrl+C in a coding agent does different things: raw mode and the terminal's ISIG flag

A DEV Community article explains that pressing Ctrl+C in Claude Code can clear a draft or exit depending on context, which a standard Unix SIGINT cannot decide. Normally the kernel's terminal driver converts the Ctrl+C byte (0x03) into a SIGINT sent to the whole foreground process group. When the ISIG flag is disabled, the byte is delivered to the program as ordinary input, so the program chooses the response. The author demonstrates this with stty and a short sleep test, and notes that terminal UIs use raw mode, which clears ISIG, to receive every keystroke immediately. The piece then reconstructs the agent's behaviour in a small Node.js script that handles the Ctrl+C byte itself.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in