kill信號量

kill命令
kill [-signal|-s signal|-p] [-q value] [-a] [--] pid|name...
kill -l [number] | -L
 The command kill sends the specified signal to the specified processes or process groups.

       If  no signal is specified, the TERM signal is sent.  The default action for this signal is to terminate the process.  This signal should be used in preference
       to the KILL signal (number 9), since a process may install a handler for the TERM signal in order to perform clean-up steps before terminating  in  an  orderly
       fashion.   If  a  process  does  not  terminate  after a TERM signal has been sent, then the KILL signal may be used; be aware that the latter signal cannot be
       caught, and so does not give the target process the opportunity to perform any clean-up before terminating.
大致意思
kill命令將指定的信號發送到指定的進程或進程組。如果未指定信號,則發送TERM信號。此信號的默認操作是終止進程。這個信號應該優先使用 因爲該信號可以設置一個回調  在進程終止之前執行資源的清理與回收 如果進程在該信號發送之後沒有被終止 那麼可以在發送KILL信號 該信號不能捕獲 因此不能爲目標進程設置回調
說人話就是  先kill  在kill -9

查詢kill的信號

[root@ip-172-31-31-182 ~]# kill -l
 1) SIGHUP	 2) SIGINT	 3) SIGQUIT	 4) SIGILL	 5) SIGTRAP
 6) SIGABRT	 7) SIGBUS	 8) SIGFPE	 9) SIGKILL	10) SIGUSR1
11) SIGSEGV	12) SIGUSR2	13) SIGPIPE	14) SIGALRM	15) SIGTERM
16) SIGSTKFLT	17) SIGCHLD	18) SIGCONT	19) SIGSTOP	20) SIGTSTP
21) SIGTTIN	22) SIGTTOU	23) SIGURG	24) SIGXCPU	25) SIGXFSZ
26) SIGVTALRM	27) SIGPROF	28) SIGWINCH	29) SIGIO	30) SIGPWR
31) SIGSYS	34) SIGRTMIN	

常用信號 
INT(2) 中斷 如ctrl+c    QUIT(3)  優雅的殺死進程 等待進程結束  KILL(9)強制殺死進程  不能捕獲、阻塞、忽略  可能有殘餘   TERM(15)快速的殺死進程   
3和15都不一定能殺死 最終還得靠9    
nginx
HUP(1) 熱加載配置文件  USR1(10) 重新打開日誌文件 即日誌文件切割  
USR2(12) master 根據配置文件fork出新的master和worker  WINCH(28) master優雅的幹掉worker

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章