Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trap command question ...

Status
Not open for further replies.

hokky

Technical User
Nov 9, 2006
170
AU
Hi guys,

I just wanna know what number in trap if I wanna run the remove command if someone does kill -9 [pid]

at the moment my trap applied like this :
Code:
trap "rm -f $LOCK ; exit 1" 1 2 3 15

Could you guys point me to reference what number in trap do what ? until now just those four numbers that I know.

Thanks heaps guys
 
You would be better off using the signal names instead of the numbers. Use "trap -l" to get the signal names. You probably want SIGKILL (number 9).
 
The command
[tt] kill -l[/tt]
will list the signals names and numbers.


[tt]kill -9[/tt] will, of course, send the number 9, which corresponds to [tt]SIGKILL[/tt]. But your application doesn't get a chance to respond to a [tt]SIGKILL[/tt] (that's the point of sending that signal), so watching for it in a [tt]trap[/tt] won't do any good.
 
Hi TonyGroves,

You mean command like this :
Code:
trap -l "rm -f $LOCK ; exit 1" SIGKILL
 
I have tried either of these command is not working.

Code:
trap -l "rm -f $LOCK ; exit 1" SIGKILL
or
trap -l SIGKILL "rm -f $LOCK ; exit 1"

the result is :
./load.ksh[33]: trap: -l: unknown option

Any idea guys ?
 
> if I wanna run the remove command if someone does kill -9 [pid]
You can't, because as chipperMDW, it never gets sent to the process.

In the manual page, it says "cannot be caught or ignored".

In monopoly terms, do not pass go, do not collect $200.

Using kill -9 is an exceptional case used only when the process refuses to pay any attention by any other method. It should not be used as a matter of course when it should respond normally to those other signals.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top