|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-05-20 19:31 UTC] mfischer@php.net
[2002-05-22 03:54 UTC] mfischer@php.net
[2002-06-02 10:06 UTC] mfischer@php.net
[2002-06-03 11:04 UTC] polone at townnews dot com
[2002-06-03 11:50 UTC] mfischer@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 15 09:00:01 2025 UTC |
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