php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #33147 proc_open(): "pty pseudo terminal not supported on this system"
Submitted: 2005-05-26 07:06 UTC Modified: 2021-07-23 10:30 UTC
Votes:17
Avg. Score:4.5 ± 0.8
Reproduced:15 of 15 (100.0%)
Same Version:4 (26.7%)
Same OS:8 (53.3%)
From: skissane at iips dot mq dot edu dot au Assigned: nikic (profile)
Status: Closed Package: Program Execution
PHP Version: 5CVS-2005-05-27 OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: skissane at iips dot mq dot edu dot au
New email:
PHP Version: OS:

 

 [2005-05-26 07:06 UTC] skissane at iips dot mq dot edu dot au
Description:
------------
Trying to use Unix98 pty's with proc_open gives error " pty pseudo terminal is not support on this system in ". But, /dev/ptmx exists, and devpts is mounted on /dev/pts!

PHP configuration: 

'./configure' '--enable-cli' '--disable-cgi' '--with-xsl' '--prefix=/usr/local/php-5.0.4/' '--with-dba' '--with-cdb' '--with-mssql=/usr/local'




Reproduce code:
---------------
<?php
// Create a pseudo terminal for the child process
$descriptorspec = array(
   0 => array("pty"),
   1 => array("pty"),
   2 => array("pty")
);
$process = proc_open("ls -l /", $descriptorspec, $pipes);
if (is_resource($process)) {
        echo "OK!";
}
else {
        echo "FAIL!";
}
?>


Expected result:
----------------
OK!

Actual result:
--------------
Warning: proc_open(): pty pseudo terminal is not support on this system in /home/skissane/php-5.0.4/ptytest.php on line 8
FAIL!


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-26 10:16 UTC] tony2001@php.net
Please test the patch in this letter:
http://www.mail-archive.com/internals@lists.php.net/msg14854.html
 [2005-05-27 01:29 UTC] skissane at iips dot mq dot edu dot au
Tested with the patch you supplied. (Patch would not apply, so I had to apply most of it by hand.) My test case works with the test you supplied, and --enable-pty supplied as a config option.
 [2005-05-30 03:07 UTC] skissane at iips dot mq dot edu dot au
Wez (or someone else with CVS comitter rights): why not just check Michael Spector's patch into CVS? http://www.mail-archive.com/internals@lists.php.net/msg14854.html.

That should close this issue. No more of your time required :)
 [2005-05-30 08:20 UTC] skissane at iips dot mq dot edu dot au
Updated test case: added SKIPIF (requires Michael Spector's --enable-pty patch).

--TEST--
Bug #33147 (proc_open: basic test of Unix98 PTYs functionality)
--SKIPIF--
<?php
ob_start();
phpinfo();
$info = ob_get_contents();
ob_end_clean();
if (strpos($info,"--enable-pty") === FALSE) {
        die("skip --enable-pty not specified\n");
}
?>
--FILE--
<?php
// Create a pseudo terminal for the child process
$descriptorspec = array(
   0 => array("pty"),
   1 => array("pty"),
   2 => array("pty")
);
$process = proc_open("echo this is working", $descriptorspec, $pipes);
if (is_resource($process)) {
        echo "OK\n";
        while (!feof($pipes[1]))
                echo fread($pipes[1],1024);
}
?>
--EXPECT--
OK
this is working
 [2005-06-20 09:51 UTC] skissane at iips dot mq dot edu dot au
This is not really a feature/change request -- the feature is already supported in the code; the configure system just needs to be set up so the support can be turned on/off.
 [2005-07-14 08:57 UTC] sniper@php.net
I'm still waiting for someone to give me a short and reliable piece of code (shell or C) to test if the functionality is present on the system..

 [2006-02-14 11:28 UTC] justinhead at insightbb dot com
You can use basic shell tools to test system pty piping.  The following works on FreeBSD 6.0 but you may have to change the names of your pty/tty devices for other unixes.

Open up two terminal sessions and become root in both.

In the first one type:
ping localhost | tee /dev/ptyp9

In the second one type:
cat < /dev/ttyp9

Thats it.  If pty's are working you should start seeing the output of the ping command scroll by in both terminals.
 [2010-09-01 12:35 UTC] jani@php.net
-Package: Feature/Change Request +Package: *General Issues -Assigned To: sniper +Assigned To:
 [2014-05-12 11:33 UTC] gescheit at list dot ru
Sadly, but "bug" still present.
This code can be used for pty checking:

#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <pty.h>

int main(int argc, char** argv) {
    int master;
    int slave;
    return openpty(&master,&slave,NULL,NULL,NULL);
}
 [2017-10-08 10:44 UTC] bwg at briangortney dot com
This appears to still be an issue?  There are legitimate uses for this, so not sure why it's being ignored?  Looks like there's a patch, even.
 [2017-10-08 11:53 UTC] spam2 at rhsoft dot net
things like "open two terminal sessions and become root in them" in the existing comments are hardly helpful because nobody ever should run

./configure
make test

as root and so whatever somebody proposes needs to work in a completly restricted environment and must not fail in headless builds like distributions and everybody building packages for distribution ones to override are using (sise open buildserver, Fedora koji)
 [2017-10-08 12:56 UTC] bwg at briangortney dot com
But aren't those comments irrelevant?  The patch adds the '--enable-pty' option, which would leave it up to the user and/or distribution to enable pty support.  In cases where the user or distro package manager knows Unix 98 ptys are supported, they can --enable-pty; otherwise, nothing changes.  It doesn't seem it needs to be 'smarter' than that, to me.  At the very least, allowing ptys to be used in this way, rather than just disabling entirely (#if 0), is a step in the right direction.

I'm going to apply the patch to 7.1.10 (manually, I'm sure) and test this morning; will post the diff (or a PR on github if that's preferred) if it still works.  Looks like it should?
 [2018-02-11 17:52 UTC] cmb@php.net
-Package: *General Issues +Package: Program Execution
 [2021-07-23 10:30 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2021-07-23 10:30 UTC] nikic@php.net
proc_open() pty support was added back in PHP 8.0: https://github.com/php/php-src/commit/a84cd96e865db795edc72b2799eac5c3c67aadfe
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC