oren-py-l at hishome.net
Tue Sep 10 16:30:13 CEST 2002
On Tue, Sep 10, 2002 at 12:33:05PM +0200, Bo M. Maryniuck wrote:
> Hi, all.
> Somebody know how to list all the processes in RIGHT way on Linux/UNIX?
> I need to find the zombies, stopped processes etc.
Ah, it's tricky. The output of the ps command is not consistent and the
native API can be anything from variations on a /proc filesystems to
actually looking at the kernel data structures. It's a lot of work to
support all these different interfaces.
Fortunately, someone already did the hard work - the lsof utility:
It lists all open files on the system and as a side-effect also reports
a great deal of information about processes. It also has an output mode
designed for parsing by other programs. It works for a large number of
different platforms and is installed by default on many systems.
Opening lsof with popen and decoding the output should be trivial.
More information about the Python-list