Operating System - HP-UX
1833030 Members
2557 Online
110049 Solutions
New Discussion

how to trap suspend signal

 
SOLVED
Go to solution
Mauro Gatti
Valued Contributor

how to trap suspend signal

Hi all,
I'd like to trap ctrl+z (suspend ?) signal.

I think to do something like this :

trap s

s () {
....

}

It is correct?
is 24?

Thank You
Ubi maior, minor cessat!
3 REPLIES 3
Shannon Petry
Honored Contributor

Re: how to trap suspend signal

Looks correct. If you look a bit into the trap, you can also trap multiple system calls.
I.E.

trap 'exit_fc' 1 2 3 4 5 6 7

exit_fc() {
# do stuff here...
}

Regards,
Shannon
Microsoft. When do you want a virus today?
Rick Tuck
New Member
Solution

Re: how to trap suspend signal

I don't think you can trap a signal 24, but in my testing I trapped a signal 25 just fine which prevented the users from using ctrl-z.
Olivier ROBERT
Frequent Advisor

Re: how to trap suspend signal

Hi,

Signal 24 is SIGSTOP, which cannot be caught or ignored, hence not trap'ed. But eventually, SIGTSTP (number 25) is sent when you press CTRL+Z. The default behaviour of SIGTSTP is to trigger a SIGSTOP, but this one can be caught or ignored, hence trap'ed. So you have to use signal 25 instead of signal 24.
Regards,

Olivier