mail notification at login

Jonathan I. Kamens jik at athena.mit.edu
Thu Feb 7 17:48:17 AEST 1991


  /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 at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.misc mailing list