for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace AsyncPHP\Process;
class PosixHandler implements Handler
{
/**
* @var int
*/
private $pid = 0;
* @inheritdoc
*
* @param string $id
* @param string $command
* @param bool $background
public function start($id, $command, $background = false)
$shhh = "";
if ($background) {
$shhh = " > /dev/null 2> /dev/null &";
}
passthru("ASYNCPHP_PROCESS_ID={$id} {$command} {$shhh}");
* @return bool
public function running($id)
$switch = "e";
if (stristr(PHP_OS, "DAR")) {
$switch = "E";
exec("ps {$switch} | grep \"[A]SYNCPHP_PROCESS_ID={$id}\"", $output);
if (count($output)) {
$line = trim($output[0]);
$values = explode(" ", $line);
$this->pid = (int) $values[0];
return true;
return false;
public function stop($id)
if ($this->running($id) && $this->pid) {
exec("kill -9 {$this->pid}");