From: [EMAIL PROTECTED]
Operating system: Linux
PHP version: 4.2.0
PHP Bug Type: POSIX related
Bug description: posix_isatty wants a long instead of resource
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 bug report at http://bugs.php.net/?id=17323&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17323&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17323&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17323&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17323&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17323&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17323&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17323&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17323&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17323&r=globals