In linux, complete the following shell script snippet, to ensure on_exit function is run whenever the SIGINT signal is sent (i.e. when user presses ctr-c):
^^ note the use of trap built-in command to bind the signal SIGINT to function on_exit
^^^ note the order of command line arguments given to trap, i.e. the binding functon is given first, then the signal
Question
In linux, complete the following shell script snippet, to ensure on_exit function is run whenever the SIGINT signal is sent (i.e. when user presses ctr-c):
In linux, complete the following shell script snippet, to ensure on_exit function is run whenever the SIGINT signal is sent (i.e. when user presses ctr-c):
^^ note the use of trap built-in command to bind the signal SIGINT to function on_exit
^^^ note the order of command line arguments given to trap, i.e. the binding functon is given first, then the signal
If you want to change selection, open document below and click on "Move attachment"
20. Advanced Shell Scripting recieved' } trap on_hangup SIGHUP while true ; do sleep 1 done exit 0 Run the above script and then send the process ID the -HUP signal to test it. (See Section 9.5.) An important function of a <span>program is to clean up after itself on exit. The special signal EXIT (not really a signal) executes code on exit of the script: 5 10 #!/bin/sh function on_exit () { echo 'I should remove temp files now' } trap on_exit EXIT while
Summary
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.