def kill (chdir, procname = None, include_children = True, signaling = True):
import psutil
for i in range (2):
pid = status (chdir, procname)
if not pid:
break
if signaling:
os.kill (pid, signal.SIGTERM)
time.sleep (2)
if include_children:
try:
killtree.kill (pid, True)
except psutil.NoSuchProcess:
pass
while processutil.is_running (pid, procname):
time.sleep (1)
try:
os.remove (os.path.join (chdir, ".pid"))
except FileNotFoundError:
pass
评论列表
文章目录