I just read about the trap command and how to use it but i have failed to understand how it actually works, when dealing with processes.
I would like to also know how to use the trap statement in shell scripts to capture interrupts to a script.
Thanks in advance.
For example, if you made a trap on a script that do some jobs in the server and the user tried to cancel it by hitting Ctrl + C, it won’t be cancelled and will provide a message you chose.
trap "echo Terminating the script while working may leave your system corrupted, Please wait; sleep 2" SIGINT SIGTERM