Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.misc Subject: Re: mail notification at login Message-ID: Date: 7 Feb 91 06:48:17 GMT References: <1991Feb6.233242.15852@nntp-server.caltech.edu> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 35 In-Reply-To: allen@nntp-server.caltech.edu's message of 6 Feb 91 23:32:42 GMT /bin/login (or whatever checks for new mail when the user logs in) uses the following algorithm to figure out what message to print: 1. Stat() the user's mail file. 2. If the stat() fails, or if the st_size member of the stat structure is equal to 0, then exit the algorithm (i.e. don't print anything). 3. If the st_mtime (the *modification* time of the file) is later than the st_atime (the *access* time of the file), then print "You have new mail." and exit the algorithm. 4. Print "You have mail." and exit the algorithm. When root cat's the user's mail file, the access time is set to the current time, which is later than the last modification time, so login assumes that the user has read the mail and put it back into his mailbox. When the first mail message is sent to the user and the file is created, then the access time is equal to the last modification time, so login assumes once again that the user has read the mail and put it back into his mailbox. However, when a message is sent to the user and then nothing else happens before the user logs in, then the modification time is later than the access time, so login prints the "new mail" message. I hope this clarifies things. Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710