Link to home
Start Free TrialLog in
Avatar of ymlew
ymlew

asked on

trap CTRL-C and kill -9

In my shell script, I tried to trap CTRL-C and "kill -9" as follow:
_abort()
{
   kill ${PID}
   echo "kill " ${PID}
}

trap _abort 2 15

However, it seems that when the user press CTRL-C, it got trap and the kill message is being printed.

However, when the user press "kill -9 Pid", the kill message is not being printed.

Is there anywhere to trap a kill -9 signal???
ASKER CERTIFIED SOLUTION
Avatar of rdelfino
rdelfino

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
NO.
See man kill.
Avatar of Moondancer
Moondancer

This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
https://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thanks,
Moondancer
Moderator @ Experts Exchange