mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-01-26 11:33:59 +00:00
22 lines
401 B
Plaintext
22 lines
401 B
Plaintext
---
|
|
syntax: markdown
|
|
tags: [tldr, common]
|
|
source: https://github.com/tldr-pages/tldr.git
|
|
---
|
|
# trap
|
|
|
|
> Execute a command upon an event.
|
|
> More information: <https://manned.org/trap.1posix>.
|
|
|
|
- List the commands and the names of the expected events:
|
|
|
|
`trap`
|
|
|
|
- Execute a command when a signal is received:
|
|
|
|
`trap 'echo "Caught signal {{SIGHUP}}"' {{HUP}}`
|
|
|
|
- Remove commands:
|
|
|
|
`trap - {{HUP}} {{INT}}`
|