8000 Adds PTY mode & convenience method mustRun() by schmittjoh · Pull Request #8655 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Adds PTY mode & convenience method mustRun() #8655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 3, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
attempts to fix tests on Travis
  • Loading branch information
schmittjoh committed Aug 3, 2013
commit 6c11207573a5f74af80c0131eacd0cd315b5d2df
23 changes: 22 additions & 1 deletion src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,27 @@ class Process
159 => 'Bad syscall',
);

/**
* Returns whether PTY is supported on the current operating system.
*
* @return Boolean
*/
public static function isPtySupported()
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
return false;
}

$proc = @proc_open('echo 1', array(array('pty'), array('pty'), array('pty')), $pipes);
if (is_resource($proc)) {
proc_close($proc);

return true;
< 8000 summary hidden="hidden" role="button" data-target="details-collapsible.summaryElement details-toggle.summaryTarget" data-action="click:details-collapsible#toggle click:details-toggle#toggle" data-aria-label-closed="Expand comment" data-aria-label-open="Collapse comment" data-aria-label-closed="Expand" data-aria-label-open="Collapse" aria-expanded="true" aria-label="Collapse" data-view-component="true" class="py-2 px-3 rounded-2 color-bg-subtle">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you keep this value in a property to avoid creating a new process each time the support of Pty is checked ?

}

return false;
}

/**
* Constructor.
*
Expand Down Expand Up @@ -1183,7 +1204,7 @@ private function getDescriptors()
array('file', '/dev/tty', 'w'),
array('file', '/dev/tty', 'w'),
);
} elseif ($this->pty) {
} elseif ($this->pty && self::isPtySupported()) {
$descriptors = array(
array('pty'),
array('pty'),
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ public function testTTYCommand()
*/
public function testPTYCommand()
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$this->markTestSkipped('Windows does not have PTY support.');
if ( ! Process::isPtySupported()) {
$this->markTestSkipped('PTY is not supported on this operating system.');
}

$process = $this->getProcess('echo "foo"');
Expand Down
0