X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Message-Id: From: Denis Excoffier To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: modification time of standard input is wrong Date: Tue, 16 Mar 2010 18:24:27 +0100 Cc: Denis Excoffier Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 Hello, Under Cygwin 1.7.1-1, i have created the small program (see below), to print the modification time of the standard input. In the case where the stdin is a pipe (or the terminal), i expect the result to be more or less the current time. But the time printed in this case is invariably the modification time of /dev/null. This has some impact in gzip and further, in tar. Thank you for your help. See below for the details. Denis Excoffier. --------------------------------- #include #include #include // int main() { // struct stat s; if (fstat(fileno(stdin), &s) != 0) { fprintf(stderr, "error fstat\n"); } else { struct tm *tm = localtime(&s.st_mtime); if (tm) { printf("%u\n", s.st_mtime); printf("%04u-%02u-%02u %02u:%02u:%02u\n", 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); } else { fprintf(stderr, "error localtime\n"); }; }; return(0); }; --------------------------------- % uname -s CYGWIN_NT-5.1 % setenv TZ UTC % gcc -o myprog myprog.c % ./myprog < myprog.c 1268727969 2010-03-16 08:26:09 % ./myprog 1164931200 2006-12-01 00:00:00 % ls -lgG --full-time /dev/null crw-rw-rw- 1 1, 3 2006-12-01 00:00:00.000000000 +0000 /dev/null % tar czf - /etc/passwd | (od --skip-bytes=4 -l -N4; cat > /dev/null) tar: Removing leading `/' from member names 0000004 1164931200 0000010 % -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple