当我在阻塞模式下从管道读取时,我有一个python代码,当我单击control + c并发送SIGINT时,进程不会捕获它。只有在我在管道中发送一些数据后,才会激活SIGINT方法。如何在读取中读取SIGINT? (python代码在Linux上运行) 这是我从管道代码中读到的
while(msg.find(EOM) == -1):
print "cp1"
char= cpp_to_python_pipe.read(1)
print "cp2"
这是SIGINT处理程序
def sigterm_handler(_signo, _stack_frame):
#get sigint signal and send event to the cpp
print "terminated by user signal(" +str(_signo) + ")"
send_event_to_cpp("<on_sigint>")
os._exit(0)