check for a running subprocess
Randall Hopper
aa8vb at yahoo.com
Tue Jun 6 12:32:24 EDT 2000
Dirk Moebius:
|
|I don't know whether that's a python or unix question, but:
|
|How do I check whether a subprocess of the current process is still
|running? Let's say, the current process is called 'dial' and the
|subprocess is called 'fetchmail'. The subprocess is not necessarily a
|_direct_ successor of the current process.
If you know the pid, then see kill(2). Call kill with a signal of 0. In
C, the return value is set. In Python, you'll probably get an OSError
exception if the process doesn't exist.
If you don't know the pid, I would find a way to get it and use the above.
Otherwise you have to resort to ugly popen( "ps -psargs" ) or /proc tricks
which are system-specific.
Though, if you have only one target OS with no chance of porting, then the
latter may be reasonable.
--
Randall Hopper
aa8vb at yahoo.com
More information about the Python-list
mailing list