php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63639 posix_isatty and posix_ttyname weird var handling
Submitted: 2012-11-28 21:55 UTC Modified: 2013-10-02 07:08 UTC
From: antronin at gmail dot com Assigned:
Status: Not a bug Package: POSIX related
PHP Version: Irrelevant OS: Ubuntu 12.10
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: antronin at gmail dot com
New email:
PHP Version: OS:

 

 [2012-11-28 21:55 UTC] antronin at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.posix-isatty
---
Although documentation says "Returns TRUE if fd is an open descriptor connected 
to a terminal and FALSE otherwise." clearly this is not the case. 
It also returns TRUE if the parameter is not a file descriptor at all except is 
it is an integer < 3.

Test script:
---------------
var_dump(posix_isatty(true));
var_dump(posix_isatty(false));
var_dump(posix_isatty('str'));
var_dump(posix_isatty(array()));
var_dump(posix_isatty(42));

for ($i=0; $i<50; $i++) {
    var_dump(posix_isatty($i));
}


Expected result:
----------------
(bool)false
(bool)false
(bool)false
(bool)false
(bool)false

(bool)false x50

Actual result:
--------------
(bool)true
(bool)true
(bool)true
(bool)true
(bool)false

(bool)true
(bool)true
(bool)true
(bool)false x47

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-02 07:08 UTC] mike@php.net
-Status: Open +Status: Not a bug
 [2013-10-02 07:08 UTC] mike@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Expecting integer parameters the arguments get converted, so:

true -> 1 -> STDOUT
false/'str'/array() -> 0 -> STDIN
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 18:01:27 2024 UTC