php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69105 posix_isatty(): could not use stream of type 'MEMORY'
Submitted: 2015-02-22 20:50 UTC Modified: 2015-12-02 19:53 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: ianbytchek at gmail dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.6.6 OS: OS X 10.10.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ianbytchek at gmail dot com
New email:
PHP Version: OS:

 

 [2015-02-22 20:50 UTC] ianbytchek at gmail dot com
Description:
------------
I've raised the original issue at https://github.com/symfony/symfony/issues/13759. There's a very common check if the stream supports colours / interactivity by doing this:

return function_exists('posix_isatty') && @posix_isatty($stream);

But it fails for some reason and gives me this:

posix_isatty(): could not use stream of type 'MEMORY'

If I rewrite it with try … catch block it works:

try {
    return function_exists('posix_isatty') && posix_isatty($stream);
} catch (\Exception $exception) {
    return false;
}

But from what I understand that's what `@` in front of the first posix_isatty example call does. Did that change recently in 5.6 or what might be the problem here? I seem to be the only one who's getting this issue.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-02 19:53 UTC] bishop@php.net
-Status: Open +Status: Not a bug
 [2015-12-02 19:53 UTC] bishop@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

posix_isatty() does not raise an exception in the 5.6 series. You can verify this with this simple script (also at https://3v4l.org/R8N1L#v566):

function test_posix_isatty() {
    assert('function_exists("posix_isatty")');
    return posix_isatty(fopen('php://memory', 'w'));
}

var_dump(
    PHP_VERSION,
    test_posix_isatty()
);

I suspect you have a global error handler that is translating warnings into exceptions. (Note in your example with the try...catch block, there is no @-silencer on posix_isatty.)
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 23 03:01:29 2019 UTC