note 72018 rejected from function.posix-isatty by nlopess

From: Date: Fri, 29 Dec 2006 14:34:17 +0000
Subject: note 72018 rejected from function.posix-isatty by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-121008@lists.php.net to get a copy of this message
Note Submitter: brion at pobox dot com ---- 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

« previous php.notes (#121008) next »