/bin/mail times out on lock files too quickly

Mark Plotnick mp at allegra.UUCP
Sat Feb 22 22:40:54 AEST 1986


<>
Index:	bin/mail 4.2BSD Fix

Description:
	/bin/mail tries to create a lock file for only 30 seconds.
	Since /usr/ucb/Mail can take longer than this to rewrite
	a mailbox, /bin/mail may append a message to the mailbox
	only to have it overwritten (or otherwise gotten rid of by the
	ftruncate that Mail performs) a few seconds (or minutes) later.
Repeat-By:
	Have a large mailbox.  Read mail on a loaded machine (fire up
	a couple of uucico's, troff's, and vlsi simulators to test this
	out; this will make you popular with the system staff, one way
	or the other).  Edit or delete some messages, and type q.
	If someone tries to send you mail before the mailbox
	is completely rewritten, you'll get a biff message and that's
	the last you'll ever see of the mail.

	Actually, all is not lost; you can take advantage of
	the fact that ftruncate doesn't zero out the last partial
	block of a file (this is documented in the BUGS (4.2BSD)
	or RESTRICTIONS (Ultrix) section of the man page) and write
	a program to seek past the end of the file and write a character,
	then pull the mailbox into an editor and hopefully
	extract the newly unearthed message.
Fix:
	I also increased the number of times that it will
	tolerate a disappearing lock file.  ../ucb/Mail/lock.c
	should probably also be fixed in this regard, since it
	only tries once.

	RCS file: mail.c,v
	retrieving revision 1.1
	diff -c -r1.1 mail.c
	*** /tmp/,RCSt1005526	Sat Feb 22 07:09:01 1986
	--- mail.c	Fri Aug  9 09:03:40 1985
	***************
	*** 725,731
				return(0);
			}
			if (stat(curlock, &sbuf) < 0) {
	! 			if (statfailed++ > 5)
					return(-1);
				sleep(5);
				continue;

	--- 725,731 -----
				return(0);
			}
			if (stat(curlock, &sbuf) < 0) {
	! 			if (statfailed++ > 200)
					return(-1);
				sleep(5);
				continue;
	***************
	*** 732,738
			}
			statfailed = 0;
			time(&curtime);
	! 		if (curtime < sbuf.st_ctime + 30) {
				sleep(5);
				continue;
			}

	--- 732,738 -----
			}
			statfailed = 0;
			time(&curtime);
	! 		if (curtime < sbuf.st_ctime + 1800) {
				sleep(5);
				continue;
			}

	Mark Plotnick
	Society for the Prevention of Mail Bugs
	allegra!mp



More information about the Comp.unix.wizards mailing list