[Lazarus] RE : How to enumerate list of Linux running processes?

Ludo Brands ludo.brands at free.fr
Sun Aug 14 10:52:03 CEST 2011


> On 13.08.2011 23:11, Frank Church wrote:
> > Is there a Lazarus/FPC routine to list the processes running on a 
> > Linux system, the equivalent of EnumProcesses + 
> > GetCommandLineEx(Pids[x]) on Windows?
> 
> There is no cross platform way for that so you either need to 
> list the 
> files in "/proc" (those directories that contain only a number are 
> processes) or parse the output of e.g. "top". "top" itself 
> afaik scans 
> "/proc" as well.
> 
> Regards,
> Sven
> 
Perhaps parsing the ps output is easier since output is already quite
configurable. ps is also parsing /proc.
As long as you stick to linux, this solution can be made portable between
the different flavors. Portablility with other unix's is problematic.

Ludo





More information about the Lazarus mailing list