Given PID, make sure a process is running on Unix?

VanL news at lindbergs.org
Sun Jul 7 01:04:11 EDT 2002


Thank you!  This is just what I was looking for.

Thanks,

VanL

François Pinard wrote:

>[VanL]
>
>  
>
>>I am trying to get write a python script that on Unix reads a PID from
>>a file and, if that process is still running, exits.  If the process is
>>not running, the process would be started.  [...] Any help?
>>    
>>
>
>You could work along the lines of:
>
>    try:
>        os.kill(PID, 0)
>    except OSError:
>        print PID, 'is not running'
>    else:
>        print PID, 'is running'
>
>Killing a process with signal 0 never kills it. :-)
>
>  
>








More information about the Python-list mailing list