How to check whether specified PID is currently running without invoking ps from PHP?
If you are on Linux, try this :
if (file_exists( "/proc/$pid" )){
//process with a pid = $pid is running
}
posix_getpgid($pid);
will return false when a process is not running
If you want to have a function for it then:
$running = posix_kill($pid,0);
Send the signal sig to the process with the process identifier pid.
Calling posix_kill
with the 0 kill signal will return true
if the process is running, false
otherwise.