我在“syslog-ng -Fevd”OSE版本3.8中运行了一个Python程序,因此我可以从命令行快速开发。当从命令行运行时,我的信号处理程序捕获control-C(我假设其他信号),但在syslog-ng内部则没有。已知信号是否在syslog-ng中传播到Python?我是Python的新手,我犯了错误吗?
#Start of syslog-ng python config
python {
def handler(signum, frame):
print 'Signal handler called with signal', signum
stopSubscription()
signal.signal(signal.SIGALRM, handler)
signal.signal(signal.SIGINT, handler)
signal.signal(signal.SIGABRT, handler)
signal.signal(signal.SIGHUP, handler)
signal.signal(signal.SIGTERM, handler)
signal.signal(signal.SIGBUS, handler)
signal.signal(signal.SIGCHLD, handler)
signal.signal(signal.SIGCLD, handler)
def stopSubscription():
print "shutdown requested"
}; # end of syslog-ng block
从命令行(control-C)和PyCharm内部(停止按钮)我得到
用信号2调用信号处理程序 请求关闭
但是来自syslog-ng,蟋蟀。
答案 0 :(得分:0)
你在Python代码中犯了一个错误。您必须导入信号模块才能注册您的功能。
但是,修复代码不会解决您的问题。如果您在Python中注册处理程序,似乎信号不会被转发到Python或syslog-ng的信号处理程序。