note 78231 deleted from function.posix-isatty by nlopess

From: Date: Fri, 05 Oct 2007 12:07:03 +0000
Subject: note 78231 deleted from function.posix-isatty by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-131134@lists.php.net to get a copy of this message
Note Submitter: Alex Kocharin, 2:50/13 Reason: spam ---- I have found this note somewhere in a http://www.phpforumz.info/, and it benefits me... 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 ine 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

« previous php.notes (#131134) next »