[Lazarus] Process ID

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Thu Sep 13 09:42:46 CEST 2012


Kaj Mikkelsen wrote:
> If I understand your question correct, you are asking for a lazarus
> function.
> I don't think that exists.
> But you can use the TProcess to execute a linux command and grab the output.
> Pidof will give you the processed of a specific program.
> Ps is much more multipurpose, and it does *not* requires you to be root.
> At leat not in RedHat/Centos
> 
> You can use the following command to find all processes for a specific user
> (using kmi as an example):
> ps aux | grep  -w ^kmi

Please use the same quoting convention as the messages you are 
responding to. The thread was already growing downwards, and adding a 
message to the top is inappropriate.

In my experience, using ps etc. is wrong since apart from the efficiency 
aspect it makes several assumptions:

i)   That the ps binary is available.

ii)  That the command-line options you need are universally implemented.

iii) That (at least in the case of Linux) the /proc filesystem is available.

I think that it's probably more portable to go straight to the values 
available in /proc, if you can't read them then it's unlikely that ps 
would show you much more.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list