Skip to content

Commit 425af5e

Browse files
committed
Added pipes for different platform, checking directory separator + added public method to return PID
1 parent 19ce603 commit 425af5e

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/Shell/Shell.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,19 @@ public function __construct(string $command, string $cwd = null, string $input =
4242

4343
private function getDescriptors()
4444
{
45-
return array(
46-
self::STDIN_DESCRIPTOR_KEY => array("pipe", "r"),
47-
self::STDOUT_DESCRIPTOR_KEY => array("pipe", "w"),
48-
self::STDERR_DESCRIPTOR_KEY => array("pipe", "r")
49-
);
45+
if ('\\' === \DIRECTORY_SEPARATOR) {
46+
return array(
47+
self::STDIN_DESCRIPTOR_KEY => array('pipe', 'r'),
48+
self::STDOUT_DESCRIPTOR_KEY => array('file', 'NUL', 'w'),
49+
self::STDERR_DESCRIPTOR_KEY => array('file', 'NUL', 'w'),
50+
);
51+
} else {
52+
return array(
53+
self::STDIN_DESCRIPTOR_KEY => array('pipe', 'r'),
54+
self::STDOUT_DESCRIPTOR_KEY => array('pipe', 'w'),
55+
self::STDERR_DESCRIPTOR_KEY => array('pipe', 'w'),
56+
);
57+
}
5058
}
5159

5260
private function setInput()
@@ -132,6 +140,11 @@ public function isRunning()
132140
return $this->status && $this->status['running'];
133141
}
134142

143+
public function getProcessId()
144+
{
145+
return $this->isRunning() ? $this->status['pid'] : null;
146+
}
147+
135148
public function stop()
136149
{
137150
if (!$this->isRunning()) {

0 commit comments

Comments
 (0)