[Lazarus] Process ID
a.fortuny at sitasoftware.lu
Thu Sep 13 10:06:07 CEST 2012
Thanks to all anyway for answering.
I've found two nice solutions to solve my problem.
To be honest I've to mention that what my function receives a paramater
which is a PID and the function has to check if that process is still
running returning a value. Sorry for any misunderstanding. I agree that
my question was ambigous from that point of view.
1. Look at /proc/<PID> as /proc has dr-xr-xr-x permissions, like
if DirectoryExistsUTF8(Format('/proc/%d', [wPID])) then
MessageDlg('OK', 'process is running', mtInformation, [mbOK], 0)
MessageDlg('OK', 'process is NOT running', mtError, [mbOK], 0);
2. use kill with signal 0
if FpKill(wPID, 0) = 0 then
MessageDlg('OK', 'FpPid process is running', mtInformation, [mbOK], 0)
MessageDlg('OK', 'FpPid process is NOT running', mtError, [mbOK], 0);
I guess that solution 2 is the best as it asks immediately the kernel.
More information about the Lazarus