I have a script: giga.sh (shell script BASH) which is running using PUTTY session.
I see most people like to copy using "Control+C" and paste as "Control+V". Few of my wise friends use mouse's right click then copy, then paste and I wondered, don't they know Control+C? They were actually right due to their experience :), like doing that when giga.sh is running for PRODUCTION deployment/task.
What I want is: if giga.sh is running and someone has multiple applications open and where they regularly perform copy/paste operation for taking copy of a text/image from those opened apps, then if Mouse control accidentally comes on the PUTTY window/session, then performing a "Control+C" should NOT, kill a running giga.sh script.
Right now my script TRAPS few signals (2 i.e. INT, 15 i.e. TERM (default) at the moment) within giga.sh.
Does that mean, all I have to do is to remove "2" from the following (see trap...line) and it'll make a running giga.sh script immune to pressing accidental control+c key by a user? I assume it will NOT as we'll not be trapping any sig 2/INT then, wondering if someone has a better idea. New trap / trap_mesg() to handle sig 2 and sig 15 separately, would do it !?
trap_mesg ()
{
#...do something here..
#...before actually exiting out...
#...do something here..
}
#####################################
## Trap signals : INT, TERM. catch ##
#####################################
#Set NULL/Blank value to trap_call. This variable will help in running trap_mesg only once during the life of this script.
trap_call="";
trap 'if [ -z ${trap_call} ]; then trap_call="1"; trap_mesg ; fi' 2 15
##################################