Bug #69105 [Opn->Nab]: posix_isatty(): could not use stream of type 'MEMORY'

From: Date: Wed, 02 Dec 2015 19:53:42 +0000
Subject: Bug #69105 [Opn->Nab]: posix_isatty(): could not use stream of type 'MEMORY'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197563@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69105&edit=1

 ID:                 69105
 Updated by:         bishop@php.net
 Reported by:        ianbytchek at gmail dot com
 Summary:            posix_isatty(): could not use stream of type
                     'MEMORY'
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Streams related
 Operating System:   OS X 10.10.2
 PHP Version:        5.6.6
 Block user comment: N
 Private report:     N

 New Comment:

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.)


Previous Comments:
------------------------------------------------------------------------
[2015-02-22 20:50:06] 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.




------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69105&edit=1


Thread (2 messages)

« previous php.bugs (#197563) next »