How to prevent termination of a running program using “ctrl+c” in Linux using python?

六眼飞鱼酱① 提交于 2019-12-05 13:03:30
import signal
def SigIntHand(SIG, FRM):
    print("Please Right click-copy. Ctrl-C does not work on the cmd prompt")

signal.signal(signal.SIGINT, SigIntHand)

or if you want it completely ignored:

import signal
signal.signal(signal.SIGINT, signal.SIG_IGN)
wting

When you hit ctrl+c it sends SIGINT to the running process. You can catch it as described here.

You can find more about the different types of signals here.

If using X, the text is normally copied to the clipboard once it's selected. Just paste it using middle mouse button or Shift+insert.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!