public function testProcessBackground() { $cmd = new Command('php', __DIR__ . '/command/basic.php'); $this->assertEquals('php ' . __DIR__ . '/command/basic.php', $cmd->getCommandLine()); $cmd->exec(true); $processes = System::processes('php'); $this->assertEquals(count($processes), Manager::os()->countProcesses('php')); $this->assertTrue(is_array($processes)); $this->assertEquals(2, count($processes)); $this->assertInstanceOf('\\Ark4ne\\Processes\\Process\\Process', $processes[0]); $this->assertInstanceOf('\\Ark4ne\\Processes\\Process\\Process', $processes[1]); $processes[1]->kill(); }
public function testKill() { $cmd = new Command('php', __DIR__ . '/command/basic.php'); if (\Ark4ne\Processes\System\OS\Manager::isWin()) { $this->assertNull($cmd->exec(true)); } else { $this->assertInstanceOf('\\Ark4ne\\Processes\\Process\\Process', $cmd->exec(true)); } $processes = System::processes('php'); $this->assertEquals(2, count($processes)); $this->assertInstanceOf('\\Ark4ne\\Processes\\Process\\Process', $processes[0]); $processes[1]->kill(); $processes = System::processes('php'); $this->assertEquals(1, count($processes)); }
/** * Execute the command. * * @param bool $background * * @return null|string|Process */ public function exec($background = false) { if ($background) { return System::processById(System::execute($this, true)); } return System::execute($this, false); }
/** * Kill the process. */ public function kill() { System::kill($this); }