getting properly one subprocess output

Nobody nobody at nowhere.com
Wed Nov 18 13:44:10 EST 2009


On Wed, 18 Nov 2009 12:25:14 +0100, Jean-Michel Pichavant wrote:

> I'm currently inspecting my Linux process list, trying to parse it in 
> order to get one particular process (and kill it).
> I ran into an annoying issue:
> The stdout display is somehow truncated (maybe a terminal length issue, 
> I don't know), breaking my parsing.

> As you can see, to complete process command line is truncated.
> Any clue on how to get the full version ?

If you only need it to work on Linux, you can just enumerate 
/proc/[1-9]*/exe or /proc/[1-9]*/cmdline.

Or you can add -ww to "ps" to avoid truncating the output.

Note that the /proc/*/exe report the actual executable. The command line
reported by "ps" (from /proc/*/cmdline) can be modified by the program, so
it doesn't necessarily reflect the program being run.





More information about the Python-list mailing list