note 72018 added to function.posix-isatty

From: Date: Fri, 29 Dec 2006 08:26:24 +0000
Subject: note 72018 added to function.posix-isatty
Groups: php.notes 
Request: Send a blank email to php-notes+get-121000@lists.php.net to get a copy of this message
I've found that, at least in recentish versions of PHP (tested 5.1.6 and 5.2.0), using STDIN or STDOUT produces a warning on Linux if you really do have a tty: $ php -r 'echo posix_isatty(STDOUT) ? "tty\n" : "pipe\n";' PHP Warning: posix_isatty(): cannot seek on a pipe in Command line code on line 1 tty $ php -r 'echo posix_isatty(STDOUT) ? "tty\n" : "pipe\n";' | cat pipe No such warning is displayed on Mac OS X so this may be quirky Linux-specific behavior. You can work around this by using the direct file descriptor numbers, which are theoretically standard: 0 for stdin, 1 for stdout, 2 for stderr: $ php -r 'echo posix_isatty(1) ? "tty\n" : "pipe\n";' tty $ php -r 'echo posix_isatty(1) ? "tty\n" : "pipe\n";' | cat pipe ---- Server IP: 66.163.161.117 Probable Submitter: 75.82.16.235 ---- Manual Page -- http://www.php.net/manual/en/function.posix-isatty.php Edit -- https://master.php.net/note/edit/72018 Del: integrated -- https://master.php.net/note/delete/72018/integrated Del: useless -- https://master.php.net/note/delete/72018/useless Del: bad code -- https://master.php.net/note/delete/72018/bad+code Del: spam -- https://master.php.net/note/delete/72018/spam Del: non-english -- https://master.php.net/note/delete/72018/non-english Del: in docs -- https://master.php.net/note/delete/72018/in+docs Del: other reasons-- https://master.php.net/note/delete/72018 Reject -- https://master.php.net/note/reject/72018 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#121000) next »