Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site eneevax.UUCP Path: utzoo!linus!decvax!harpo!seismo!rlgvax!cvl!umcp-cs!eneevax!chris From: chris@eneevax.UUCP Newsgroups: net.unix-wizards Subject: Strange time() vs. stat() bug Message-ID: <34@eneevax.UUCP> Date: Sat, 3-Dec-83 05:22:48 EST Article-I.D.: eneevax.34 Posted: Sat Dec 3 05:22:48 1983 Date-Received: Tue, 6-Dec-83 23:33:31 EST Organization: Univ. of Maryland, EE Dept. Lines: 36 I think this is a bug, but maybe someone can claim a "reasonable" reason for it: If I write to a tty device and then close it, a stat 10 seconds later usually does not show it to have been modified when I did the write+close, but instead, 5 to 10 seconds later! If I use stat() instead of time() I get the "right" value (which then remains consistent). Using sync() will also make the value remain consistent (thus "time()" will be OK in the program below). I suspect there's something odd going on with the delayed I/O system here. ---------------------------- BUG DEMONSTRATER ---------------------------- #include #include #include main () { FILE *fp; time_t shouldbe; struct stat was; char *tty, *ttyname (); tty = ttyname (0); fp = fopen (tty, "w"); fprintf (fp, "testing\n"); fclose (fp); time (&shouldbe); sleep (10); stat (tty, &was); printf ("was %d should be <= %d\n", was.st_mtime, shouldbe); } -- Chris Torek, UMCP, CSD UUCP: {allegra,seismo,brl-bmd}!umcp-cs!chris ARPA: chris@maryland CSNet: chris@umcp-cs