def _kill_process(pid, sig):
"""
Sends the signal `sig` to the process identified by `pid`. If `pid` is a process group
leader, then signal is sent to the process group id.
"""
pgid = os.getpgid(pid)
try:
logvv('[{} sending {} to {}]'.format(os.getpid(), sig, pid))
if pgid == pid:
os.killpg(pgid, sig)
else:
os.kill(pid, sig)
return True
except:
log('Error killing subprocess ' + str(pid) + ': ' + str(sys.exc_info()[1]))
return False
评论列表
文章目录