我假设关闭终端窗口(或嵌入在 IDE 中的终端窗口)会向终端中运行的进程发送某种操作系统中断信号。我怎样才能找出这个信号是什么?我正在寻找一种方法来捕获中断,运行一些清理,然后中止。我正在使用 Python 和 Windows。
最佳答案
您正在寻找 SIGHUP
SIGHUP The SIGHUP signal is sent to a process when its controlling terminal is closed. It was originally designed to notify the process of a serial line drop (a hangup). In modern systems, this signal usually means that the controlling pseudo or virtual terminal has been closed.[3] Many daemons will reload their configuration files and reopen their logfiles instead of exiting when receiving this signal.[4] nohup is a command to make a command ignore the signal.
关于python - 什么操作系统中断来自关闭终端选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22993244/