> For the complete documentation index, see [llms.txt](https://freebsdfrau.gitbook.io/serious-shell-programming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://freebsdfrau.gitbook.io/serious-shell-programming/style/trap.md).

# trap

The `trap` shell built-in supports numbers (`0`, `1`, `2`, `3`, `15`, etc), long names (`EXIT`, `SIGHUP`, `SIGINT`, `SIGQUIT`, `SIGTERM`, etc), and short names (`EXIT`, `HUP`, `INT`, `QUIT`, `TERM`, etc). Use long names:

```
trap "echo EXIT" EXIT
trap "echo received hangup signal" SIGHUP
trap "echo received interrupt signal" SIGINT
trap "echo received quit signal" SIGQUIT
trap "echo received terminate signal" SIGTERM
```
