The trap command allows you to control the way a program behaves when it receives a signal. A signal is defined as an asynchronous message that consists of a number that can be sent from one process to another.