Skip to content

Commit 304f148

Browse files
committed
Removed wait method - wasn't working - to be added
1 parent 735294c commit 304f148

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

src/Helper/Shell.php

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private function closePipes()
7373
fclose($this->pipes[self::STDERR_DESCRIPTOR_KEY]);
7474
}
7575

76-
public function execute(bool $blocking = false)
76+
public function execute()
7777
{
7878
if ($this->isRunning()) {
7979
throw new RuntimeException('Process is already running');
@@ -91,10 +91,6 @@ public function execute(bool $blocking = false)
9191
$this->updateStatus();
9292

9393
$this->startTime = microtime(true);
94-
95-
if ($blocking) {
96-
$this->wait();
97-
}
9894
}
9995

10096
public function getOutput()
@@ -112,29 +108,15 @@ public function getExitCode()
112108
return $this->status['exitcode'];
113109
}
114110

115-
public function checkTimeout()
116-
{
117-
if ($this->timeout && $this->timeout < microtime(true) - $this->startTime) {
118-
$this->stop();
119-
}
120-
121-
return $this->status;
122-
}
123-
124-
public function wait()
111+
public function isRunning()
125112
{
126-
while ($this->isRunning()) {
127-
usleep(1000);
128-
$this->checkTimeout();
129-
$this->updateStatus();
113+
if(!$this->status) {
114+
return false;
130115
}
131116

132-
return $this->status;
133-
}
117+
$this->updateStatus();
134118

135-
public function isRunning()
136-
{
137-
return $this->status && $this->status['running'];
119+
return $this->status['running'];
138120
}
139121

140122
public function getProcessId()

tests/Helper/ShellTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,14 @@ public function test_get_output()
1919
$shell->execute();
2020
$this->assertSame("hello\n", $shell->getOutput());
2121
}
22+
23+
public function test_get_process_id()
24+
{
25+
$shell = new Shell("echo hello");
26+
$shell->execute();
27+
echo '<pre>';
28+
print_r($shell->getProcessId());
29+
exit;
30+
$this->assertInternalType("int", $shell->getProcessId());
31+
}
2232
}

0 commit comments

Comments
 (0)