Tech Zone > Programming

Signals with trap

(1/1)

chakib:
Hello,

I am preparing a small class for students on signals with trap. I understood the use of this principle with the example on signal 2 SIGINT:

trap "echo hello" 2: which displays "hello" each time you press the shortcut ctrl + c.

On the other hand, I have difficulty assimilating the use of the following cases:

1. The effect of signal 3 SIGQUIT.

2. The effect of siganl 9 SIGKILL.

3. The effect of the signal 19 SIGSTOP.

Can you guide me with simple examples please?

Best regard

Mark Greaves (PCNetSpec):
I'm pretty sure SIGKILL and SIGSTOP cannot be trapped (or handled at all).
https://www.shellscript.sh/trap.html
and
https://stackoverflow.com/questions/35569659/the-signals-sigkill-and-sigstop-cannot-be-caught-blocked-or-orignored-why

Ctrl+\ will send a SIGQUIT signal to the terminal, so maybe

--- Code: ---
trap "bash -c /usr/bin/gedit" 3
--- End code ---
then Ctrl+\ should fire up /usr/bin/gedit

Navigation

[0] Message Index

Go to full version