Given PID, make sure a process is running on Unix?
Thomas Jensen
spam at ob_scure.dk
Sat Jul 6 18:35:20 EDT 2002
VanL wrote:
> Hello,
>
> 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.
>
> I have everything written except the part that makes sure the process is
> running. I have poked through the os module, but I can only seem to
> find information about the current process or child processes, not just
> some arbitrary process.
If your system has a 'proc' device, you could do something like this:
os.path.isdir('/proc/%d' % pid)
Most Unix flavours have a proc device AFAIK.
--
Best Regards
Thomas Jensen
(remove underscore in email address to mail me)
More information about the Python-list
mailing list