| 1 | <?php |
||
| 12 | class Process implements ProcessInterface |
||
| 13 | { |
||
| 14 | const LINUX_STYLE = 'linux'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var ProcessInterface |
||
| 18 | */ |
||
| 19 | protected $process; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var LoggerInterface |
||
| 23 | */ |
||
| 24 | protected $logger; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Process constructor. |
||
| 28 | * @param string $style |
||
| 29 | * @param LoggerInterface|null $logger |
||
| 30 | */ |
||
| 31 | 24 | public function __construct($style = self::LINUX_STYLE, LoggerInterface $logger = null) |
|
| 39 | |||
| 40 | /** |
||
| 41 | * Create "internal styled" process |
||
| 42 | * |
||
| 43 | * @param string $style |
||
| 44 | * @param LoggerInterface $logger |
||
| 45 | * @return ProcessInterface |
||
| 46 | */ |
||
| 47 | 24 | protected function getProcess($style, LoggerInterface $logger) |
|
| 59 | |||
| 60 | /** |
||
| 61 | * Check whether a pid is running |
||
| 62 | * |
||
| 63 | * @throws Exception\InvalidArgumentException |
||
| 64 | * @param int $pid |
||
| 65 | * @return boolean |
||
| 66 | */ |
||
| 67 | 16 | public function isRunning($pid) |
|
| 71 | |||
| 72 | /** |
||
| 73 | * Kill a process |
||
| 74 | * |
||
| 75 | * @throws Exception\InvalidArgumentException |
||
| 76 | * @param int $pid |
||
| 77 | * @param bool $wait |
||
| 78 | * @return void |
||
| 79 | */ |
||
| 80 | 14 | public function kill($pid, $wait = false) |
|
| 84 | } |
||
| 85 |