Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有什么方法可以通知系统进程何时启动、终止或完成。
我正在寻找一种侦听系统事件的侦听器,例如进程启动、停止等。
您可以启动ps命令、解析其输出并获取有关正在运行的进程的信息。我还没有找到更好的方法。如果您使用的是unix of cause。
ps
在 Windows 上有PsSetCreateProcessNotifyRoutine(). 或许可以通过ctypes.
PsSetCreateProcessNotifyRoutine()
ctypes
psutil提供了 Python 中的示例top实现。它使用轮询来枚举正在运行的进程。
psutil
top