Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <6f80c15205081812512b915f77@mail.gmail.com> Date: Fri, 19 Aug 2005 04:51:12 +0900 From: June Kim To: cygwin AT cygwin DOT com Subject: misbehavior of ftell on stdin? Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: inline X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id j7IJpL8F023385 Hello I run cygwin on Windows XP through rxvt. When I compile and run the following code: #include main() { printf("isatty=%d\n",isatty(fileno(stdin))); char *s=(char *)malloc(1024+1); char *s2=(char *)malloc(1024+1); fgets(s,1024,stdin); free(s); printf("stdio = %ld\n", ftell(stdin)); fgets(s2,1024,stdin); free(s2); printf("stdio = %ld\n", ftell(stdin)); } I input "abcdefg" followed by a nl and then "abcdefg" followed by a nl. $ gcc test1.c bash ~ $ ./a isatty=1 abcdefg stdio = 0 abcdefg stdio = 8 As you see, the first ftell's result is wrong. The first fgets is ignored. Interestingly, when I run cygwin without rxvt(just running bash.exe from the dos command line) with CYGWIN=notty, the ftell always returns -1. If CYGWIN=tty, then ftell behaves as in rxvt ; it returns 0 first and then behaves correct. Am I missing something? -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/