python - 什么操作系统中断来自关闭终端选项卡?

标签 python windows interrupt

我假设关闭终端窗口(或嵌入在 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/

相关文章:

Python:如何迭代 20 列并找到顶部列?

windows - 如何编写一个以 SYSTEM 权限运行的 Windows 8 软件?

c - 系统调用和 EINTR 错误代码

c# - 检测新创建的文件,刚刚编辑的文件

python - 具有无限循环的 Gevent 任务似乎也阻止了所有其他任务

python - 获取父节点?

java - 尝试从java调用python文件

VBA 如何获取当前用户应用程序数据文件夹的路径?

windows - 在 Windows 中重写注册表文件

go - 在发生中断时覆盖 golang 配置文件停止