ID:               17323
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Closed
+Status:           Open
 Bug Type:         POSIX related
 Operating System: Linux
 PHP Version:      4.2.0
-Assigned To:      
+Assigned To:      mfischer
 New Comment:

Reopening, problem not completely fixed, assigning to me.


Previous Comments:
------------------------------------------------------------------------

[2002-05-20 19:31:52] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

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

Reply via email to