Checking for new mail ?

dan at rna.UUCP dan at rna.UUCP
Mon Jan 16 10:25:43 AEST 1984


	I must be missing something, but I can't see any surefire way of
checking if any new mail has come into a mail file without understanding
the mail file format and crunching it.
	I'm not up on all the mail systems, but take the example of a mail
program like /bin/mail with a single mail file, along with a program like
the shell which wants to check quickly from time to time.
	You definitely check for atime greater than mtime, since that means
the user has scanned the mail file.
	If you check for size increases, that doesn't account for the chance
that the user has read some of his mail, has deleted a few items and a
short new item has been added since the last time you've checked.
	Unfortunately, UNIX doesn't seem to have a way of checking if only
a write has occurred, since atime, ctime and mtime all get updated with
a write().
	I've checked /bin/sh and /bin/csh code and am not convinced they
solve the previous situation. Perhaps if all mail programs did a final
read after each session to make atime greater than mtime.
	What am I missing ?

						Cheers,
						Dan Ts'o
						...cmcl2!rna!dan
P.S.
	One other possibility: some mail programs create a new file at
the end of a session and copy over messages which has not been deleted,
then unlink the original and link in the new file. In this situation
ctime != mtime since the last operation will be the link() rather than
the write().



More information about the Comp.unix.wizards mailing list