Newbie - Process Management

Dan Scholey scholeyd at logica.com
Tue Jun 18 03:56:14 EDT 2002


Hi,

I am hoping you can help me, I am fairly new to python (and Unix) but am
trying to solve the following problem...

I want to be able to check if a parent process has died.

At the moment I can check that a child process has died using...

        status = (os.waitpid(child, os.WNOHANG))[0]
        if status!=0:

I've looked at several manuals and can't find a similar function for parent
processes.
Obviously I know both the parent and child process id ( get_pid() /
get_ppid() ).

I have a workaround of....

        ps_line=string.split(commands.getoutput("ps -lp %s"%my_pid),"\012")
        if string.atoi(string.split(ps_line[1])[4])!=daddy:

... but I would rather not use ps.

Any ideas?

Cheers
Dan





More information about the Python-list mailing list