check whether the process is running. windows-linux
<?php
function isRunning($pid) {
$isRunning = false;
if(strncasecmp(PHP_OS, "win", 3) == 0) {
$out = [];
exec("TASKLIST /FO LIST /FI \"PID eq $pid\"", $out);
if(count($out) > 1) {
$isRunning = true;
}
}
elseif(posix_kill(intval($prevPid), 0)) {
$isRunning = true;
}
return $isRunning;
}
?>