Skip to content

Commit 455eb02

Browse files
committed
update some for proc wrapper
1 parent 2fddcef commit 455eb02

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/Proc/ProcWrapper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ public function open(): self
221221

222222
$workDir = $this->workDir;
223223
$options = $this->options;
224+
225+
$options['suppress_errors'] = true;
226+
if ('\\' === \DIRECTORY_SEPARATOR) {
227+
$options['bypass_shell'] = true;
228+
}
229+
224230
$process = proc_open($command, $this->descriptors, $this->pipes, $workDir, $this->runENV, $options);
225231

226232
if (!is_resource($process)) {

src/Proc/ProcessUtil.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
use function posix_getuid;
3333
use function pcntl_alarm;
3434
use function cli_set_process_title;
35-
use function setproctitle;
3635
use function error_get_last;
3736
use function posix_getpwnam;
3837
use function posix_getgrnam;
@@ -59,6 +58,40 @@ class ProcessUtil
5958
Signal::STOP => 'SIGSTOP',
6059
];
6160

61+
/**
62+
* Returns whether TTY is supported on the current operating system.
63+
*/
64+
public static function isTtySupported(): bool
65+
{
66+
static $isTtySupported;
67+
68+
if (null === $isTtySupported) {
69+
$isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
70+
}
71+
72+
return $isTtySupported;
73+
}
74+
75+
/**
76+
* Returns whether PTY is supported on the current operating system.
77+
*
78+
* @return bool
79+
*/
80+
public static function isPtySupported(): bool
81+
{
82+
static $result;
83+
84+
if (null !== $result) {
85+
return $result;
86+
}
87+
88+
if ('\\' === \DIRECTORY_SEPARATOR) {
89+
return $result = false;
90+
}
91+
92+
return $result = (bool) @proc_open('echo 1 >/dev/null', [['pty'], ['pty'], ['pty']], $pipes);
93+
}
94+
6295
/**********************************************************************
6396
* create child process `pcntl`
6497
*********************************************************************/

0 commit comments

Comments
 (0)