Python,检查进程是否在Windows中运行

时间:2013-08-02 09:18:18

标签: python operating-system

我需要检查python进程是否已经在运行。我的代码适用于Linux,但在Windows中我得到了 “WindowsError:参数不正确”

pid = process_number
try:
    os.kill(int(pid), 0)
    is_already_running = True
except OSError:
    is_already_running = False

有没有一种方法适用于linux和windows(localhost是windows,真正的服务器是linux)。或者,只是一种适用于Windows的方式。

0 个答案:

没有答案
相关问题