Bug #17323 Updated: posix_isatty wants a long instead of resource
| From: | mfischer@php.net | Date: | Sun, 02 Jun 2002 14:06:33 +0000 |
| Subject: | Bug #17323 Updated: posix_isatty wants a long instead of resource | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-9147@lists.php.net to get a copy of this message | ||
ID: 17323
Updated by: mfischer@php.net
Reported By: polone@townnews.com
-Status: Open
+Status: Critical
Bug Type: POSIX related
Operating System: Linux
PHP Version: 4.2.0
Assigned To: mfischer
New Comment:
Critical before 4.3 release.
Best thing is probably to use the old-style code, if someone has a
better idea, speak up.
Previous Comments:
------------------------------------------------------------------------
[2002-05-22 03:54:11] mfischer@php.net
Reopening, problem not completely fixed, assigning to me.
------------------------------------------------------------------------
[2002-05-20 19:31:52] mfischer@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a
documentation
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.
Will also be in 4.2.2 (if there will be a release).
------------------------------------------------------------------------
[2002-05-20 19:08:47] polone@townnews.com
The bug seems rather simple. Using command-line PHP, the following
fragment should work:
#!/usr/bin/php -q
<?php
$fd = fopen('php://stdout','w');
if (posix_isatty($fd))
print "yes, it is a terminal\n";
else
print "no, it is not a terminal\n";
?>
However, it appears that the function definition requires a long
passed, instead of a resource. The error message reported is:
dns:root-/usr/bin> ./test.php
PHP Warning: posix_isatty() expects parameter 1 to be long, resource
given in /usr/bin/test.php on line 4
<br />
<b>Warning</b>: posix_isatty() expects parameter 1 to be long,
resource given in <b>/usr/bin/test.php</b> on line <b>4</b
><br />
no, it is not a terminal
A workaround appears to be the following:
#!/usr/bin/php -q
<?php
$fd = fopen('php://stdout','w');
settype($fd,'int');
if (posix_isatty($fd))
print "yes, it is a terminal\n";
else
print "no, it is not a terminal\n";
?>
The explicit type-cast fixes the problem. Maybe I have settings in the
php.ini file wrong, but I don't think this function should behave like
this. Perhaps it requires just a change to the source. This is also
broke with posix_ttyname(). Am I suppose to acquire a file descriptor
another way?
Regards,
Patrick O'Lone
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17323&edit=1