From owner-freebsd-hackers Fri Nov 28 07:44:53 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id HAA20351 for hackers-outgoing; Fri, 28 Nov 1997 07:44:53 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from anlsun.ebr.anlw.anl.gov (anlsun.ebr.anlw.anl.gov [141.221.1.2]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id HAA20346 for ; Fri, 28 Nov 1997 07:44:50 -0800 (PST) (envelope-from cmott@srv.net) Received: from darkstar.home (dialin1.anlw.anl.gov [141.221.254.101]) by anlsun.ebr.anlw.anl.gov (8.6.11/8.6.11) with SMTP id IAA10882; Fri, 28 Nov 1997 08:44:37 -0700 Date: Fri, 28 Nov 1997 08:44:05 -0700 (MST) From: Charles Mott X-Sender: cmott@darkstar.home To: Stephen McKay cc: hackers@freebsd.org Subject: Re: flock() question In-Reply-To: <199711281346.XAA01518@ogre.dtir.qld.gov.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Fri, 28 Nov 1997, Stephen McKay wrote: > It's not entirely obvious from this that 1) your own exclusive lock will > not prevent you from trying to assert an exclusive lock and 2) you are > identified by your file table entry. In other words, you can lock the > same file over and over and it doesn't nest. And you and your child are > the same locker because you refer to the same file table entry. This > is the mechanism in action in the first example program. > > It's so obscure that I think a manpage rewrite is in order, probably with > some sample usage. For example, locks don't really apply to "files" > (ie dev/inode) but to "file table entries" (ie channels to files), so > an example that opens the same file twice and attempts to lock both > file descriptors would deadlock. A few of these should scare most > people off. :-) > > Please beat me to this rewrite. Otherwise it goes on my list. Bit > dusty that list, but if the "rellies" leave me alone this Christmas > we might see some action. :-) I'll try to do a rewrite and send you something within a week or two. The main problem I have is locating the relevant source code to verify exactly what is going on. There was no flock.c in /usr/src/lib/libc that I could identify and /usr/syr/sys/kern/kern_flock.c was a little opaque to me. Charles Mott