.lock files
Rob Bernardo
rob at PacBell.COM
Wed Apr 19 04:27:49 AEST 1989
In article <19163 at adm.BRL.MIL> SIMSN%NUSDISCS.BITNET at cunyvm.cuny.edu writes:
+
+
+ -rw-rw---- 1 chuase mail 5 Apr 18 18:06 chuase.lock
+ -rw-rw---- 1 root mail 96 Apr 18 17:57 root
+ -rw-rw---- 1 yanll mail 5 Apr 18 17:29 yanll.lock
+ -rw-rw---- 1 simsn mail 5 Apr 18 17:20 simsn.lock
+ drwxrwxr-x 2 root mail 48 Apr 18 17:16 :saved
+ -rw-rw---- 1 repo mail 1 Apr 18 17:06 repo.lock
+ -rw-rw---- 1 tankuany mail 3 Apr 18 16:02 tankuany.lock
+ -rw-rw---- 1 lawtongl mail 5 Apr 18 16:01 lawtongl.lock
+ -rw-rw---- 1 tansiewb mail 581 Apr 18 15:58 tansiewb
+
+
+ $ cat simsn.lock
+ 29006 $
+
+
+ The above is a portion of my /usr/mail and the contents of one of
+ the lock files is also shown. Other lock files have different numbers.
+
+ Can anyone please explain .lock files? We have a AT&T 3B4000/15 running
+ Sys V 3.1.1 and we use /bin/mail and /usr/bin/mailx
The .lock files are a convention used by programs that write to mailboxes
as a way of preventing two processes from writing to the same mailbox
at the same time. Some mail program with the current process id in the
lock file. This way another process can tell if the lock file is
obsolete or not (by checking to see if there is a process still
running with that process id.)
Isn't it odd that there should be so many lock files in that directory
just when you did your ls -l? Not really. There is a bug in mailx.
If invoked with the -e flag (often done in /etc/profile to report to a
user who is logging in on the presence of mail) it creates the lock
file but doesn't remove it. Such an obsolete lock file doesn't bother
mailx as it removes an obsolete lock file when it encounters one,
but other mail programs might work differently. I have seen
mail programs that deal with lock files in the following ways:
1. wait for the lock file to be removed
2. wait and try again and then remove the lock file
after so many tries under the assumption that
the lock file is obsolete
3. wait and try again and then give up after so many tries
I am not an expert, but I would recommend that "mail -e" be used
in place of "mailx -e" in /etc/profile so that there is no interference
with any other mail programs you might have or acquire in the future.
--
Rob Bernardo, Pacific Bell UNIX/C Reusable Code Library
Email: ...![backbone]!pacbell!pbhyf!rob OR rob at pbhyf.PacBell.COM
Office: (415) 823-2417 Room 4E850O San Ramon Valley Administrative Center
Residence: (415) 827-4301 R Bar JB, Concord, California
More information about the Comp.unix.questions
mailing list