歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Python 處理 SIGKILL 時遇到的問題

Python 處理 SIGKILL 時遇到的問題

日期:2017/3/1 10:11:33   编辑:Linux編程

很簡單的代碼:
signal.signal(signal.SIGKILL, signal_handler)

報出:
RuntimeError: (22, 'Invalid argument')

檢查一下
>>> import errno
>>> errno.errorcode[22]
'EINVAL' //指定的信號sig無效

看看man page

[...]
The signals SIGKILL and SIGSTOP cannot be caught or ignored.
[...]

So... Python自己並不檢查SIGKILL,而是直接把底層標准C的運行時錯誤返回。
SIGKILL無法捕捉,而且無法忽略。

Copyright © Linux教程網 All Rights Reserved