Trap Trap catches Posix signals and executes code as those signals appear. Sources https://www.linuxjournal.com/content/bash-trap-command http://man7.org/linux/man-pages/man7/signal.7.html