mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-09 18:39:04 +08:00
Fix: isProcessExist under Windows
This commit is contained in:
parent
b4af10b56b
commit
f227b8fbc6
@ -1,8 +1,13 @@
|
|||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
if platform.system() == "Windows":
|
||||||
def is_process_exist(pid):
|
def isProcessExist(pid):
|
||||||
|
with os.popen(f'tasklist /NH /FI "PID eq {pid}"') as p:
|
||||||
|
return p.read()[0] == "\n"
|
||||||
|
else:
|
||||||
|
def isProcessExist(pid):
|
||||||
try:
|
try:
|
||||||
os.kill(pid, 0)
|
os.kill(pid, 0)
|
||||||
except OSError:
|
except OSError:
|
||||||
@ -31,8 +36,8 @@ def orphanSlayer(ppid, spid, prekill = ""):
|
|||||||
|
|
||||||
Lme曰:「你可以通过经常拉屎,来结交朋友(」
|
Lme曰:「你可以通过经常拉屎,来结交朋友(」
|
||||||
"""
|
"""
|
||||||
while is_process_exist(ppid):
|
while isProcessExist(ppid):
|
||||||
if not is_process_exist(spid):
|
if not isProcessExist(spid):
|
||||||
return
|
return
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if prekill:
|
if prekill:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user