Path: blob/master/src/infrastructure/daemon/control/PhabricatorDaemonReference.php
13409 views
<?php12// TODO: See T13321. After the removal of daemon PID files this class3// no longer makes as much sense as it once did.45final class PhabricatorDaemonReference extends Phobject {67public static function isProcessRunning($pid) {8if (!$pid) {9return false;10}1112if (function_exists('posix_kill')) {13// This may fail if we can't signal the process because we are running as14// a different user (for example, we are 'apache' and the process is some15// other user's, or we are a normal user and the process is root's), but16// we can check the error code to figure out if the process exists.17$is_running = posix_kill($pid, 0);18if (posix_get_last_error() == 1) {19// "Operation Not Permitted", indicates that the PID exists. If it20// doesn't, we'll get an error 3 ("No such process") instead.21$is_running = true;22}23} else {24// If we don't have the posix extension, just exec.25list($err) = exec_manual('ps %s', $pid);26$is_running = ($err == 0);27}2829return $is_running;30}3132}333435