-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Learning Linux Shell Scripting
By :
If we want the shell to ignore certain signals, then we can call the trap command followed by a pair of empty quotes as a command. Those signals will be ignored by the shell process shown by either of the following commands:
$ trap " " 2 3 20 $ trap "" INT QUIT TSTP
The signals 2 (SIGINT), 3 (SIGQUIT), and 20 (SIGTSTP) will be ignored by the shell process.
If we want to reset the signal behavior to the original default action, then we need to call the trap command followed by the signal name or number as shown in the following examples, respectively:
$ trap TSTP $ trap 20
This will reset the default action of signal 20 (SIGTSTP). The default action is to suspend the process (Ctrl + Z).
Let's reassign our function to signals by the trap command:
$ trap 'echo "You pressed Control key"; exit 1' 0 1 2 15
If we do not pass any arguments after the trap command, then it lists all reassigned signals along with their functions.
We can list all the assigned...
Change the font size
Change margin width
Change background colour