How to check if process is alive?
Is there any cross platform way to check if process is alive?
And second question. How to get process PID?
I don't see how these two questions are connected to this library but I'll answer both of them.
Is there any cross platform way to check if process is alive?
If you want to check a status of a child process then there's a tryWait function what allows to check if a process has terminated. If the process you're interested in is not a child process of the calling process there's no crossplatform way available in D standard library.
How to get process PID?
If the process is a child process of the calling process and it was started with some of D standard library routines (like spawnProcess) then just call processID on the returned Pid. Otherwise it's platform dependent.
Upd: If you want to get the current process id, use thisProcessID
I mean something another. For example I have already working firefox and know it's PID. How can I check if it's running.
If it's running now, it's does not mean that it will run in next minute.
I simply want to do some monitor-app that will check app status.
Once process dies the functions like ProcessMemInfo.update (and processMemInfo) and ProcessCPUWatcher.current will start to throw exceptions. Note that OS may reuse pids of died processes for newly started processes, so the whole thing may subject to race conditions. But usually OS keeps these pids free for a while, so if you're polling info frequently enough it should be safe to assume that there's the same process under the pid as a minute ago.
I'm not aware of a reliable way of watching the non-child processes termination.