Why I am not getting signal SIGKILL on kill -9 command in bash?

后端 未结 1 1116
星月不相逢
星月不相逢 2021-02-08 10:50

In bash script I handle different signal as follows:

#!/bin/bash

sighdl () 
{
  echo \"signal caught\"
  #do something
  exit 0
}

trap sighdl SIGKILL SIGINT SI         


        
相关标签:
1条回答
  • 2021-02-08 11:29

    You cannot do that. Yes 9 is SIGKILL and Unix system by design doesn't allow any script/program to trap SIGKILL due to security reasons. Otherwise any script can trap & ignore SIGKILL which will make impossible to terminate that script by OS.

    0 讨论(0)
提交回复
热议问题