Skip to content

Instantly share code, notes, and snippets.

@pdu
Created April 12, 2013 01:24
Show Gist options
  • Save pdu/5368554 to your computer and use it in GitHub Desktop.
Save pdu/5368554 to your computer and use it in GitHub Desktop.
python判断一个进程是死是活,kill 0不真正发送信号,但是会检查进程的错误。http://linux.die.net/man/2/kill
import os, errno
def isExist(pid):
try:
os.kill(pid, 0)
return True
except OSError, e:
if e.errno == errno.ESRCH:
return False
else
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment