Created
April 12, 2013 01:24
-
-
Save pdu/5368554 to your computer and use it in GitHub Desktop.
python判断一个进程是死是活,kill 0不真正发送信号,但是会检查进程的错误。http://linux.die.net/man/2/kill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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