Adversaries may establish persistence by executing malicious content triggered by an interrupt signal. The <code>trap</code> command allows programs and shells to specify commands that will be executed upon receiving interrupt signals. A common situation is a script allowing for graceful termination and handling of common keyboard interrupts like <code>ctrl+c</code> and <code>ctrl+d</code>.

Adversaries can use this to register code to be executed when the shell encounters specific interrupts as a persistence mechanism. Trap commands are of the following format <code>trap 'command list' signals</code> where "command list" will be executed when "signals" are received.(Citation: Trap Manual)(Citation: Cyberciti Trap Statements)
Trap
source_name: mitre-attack  url: https://attack.mitre.org/techniques/T1546/005  external_id: T1546.005     source_name: Trap Manual  description: ss64. (n.d.). trap. Retrieved May 21, 2019.  url: https://ss64.com/bash/trap.html     source_name: Cyberciti Trap Statements  description: Cyberciti. (2016, March 29). Trap statement. Retrieved May 21, 2019.  url: https://bash.cyberciti.biz/guide/Trap_statement     