From owner-freebsd-bugs Mon Nov 19 2:41:49 2001 Delivered-To: freebsd-bugs@freebsd.org Received: from lion.com.ua (lion.com.ua [213.133.161.130]) by hub.freebsd.org (Postfix) with ESMTP id CE98237B416; Mon, 19 Nov 2001 02:41:42 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by lion.com.ua (8.11.6/8.11.6) with ESMTP id fAJAfKx68272; Mon, 19 Nov 2001 12:41:21 +0200 (EET) (envelope-from sa@simon.org.ua) Date: Mon, 19 Nov 2001 12:41:20 +0200 (EET) From: Andrey Simonenko X-X-Sender: sa@lion.com.ua To: Maxim Konovalov Cc: iedowse@FreeBSD.ORG, Subject: Re: kern/23353: fcntl(F_GETLK) return l_pid equal to -1 for the file loked with flock() In-Reply-To: <20011119110731.W52791-100000@news1.macomnet.ru> Message-ID: <20011119121136.P68006-100000@lion.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Mon, 19 Nov 2001, Maxim Konovalov wrote: > OK, just imagine a process got a lock by flock(2) and then fork(2)ed > nine children, so we have ten processes with the same lock. What do > you expect to find in flock.l_pid now? Imho l_pid is about clueless > here because of the lock inheritance. Probably l_pid should be equal to the PID of the parent and then, when the parent is terminated, it should be equal to one of its childs, and so on. > > Historically, flock(2) is a BSD interface and fcntl(F_???LK) is a > POSIX one. They can be used concurrently for locking but there is a > feature which I described above. Take a look at the line 517 > kern_lockf.c (1.25): > > if (block->lf_flags & F_POSIX) > fl->l_pid = ((struct proc *)(block->lf_id))->p_pid; > else > fl->l_pid = -1; > Thanks, I understood. > > flock(2) call (at least in my experiments). Also I haven't find any > > information about this in manual pages. > > Agree. > > What about this patch for fcntl.2: > > Index: fcntl.2 > =================================================================== > RCS file: /vol0/cvs/ncvs/src/lib/libc/sys/fcntl.2,v > retrieving revision 1.35 > diff -u -r1.35 fcntl.2 > --- fcntl.2 2001/10/26 17:38:20 1.35 > +++ fcntl.2 2001/11/19 09:18:09 > @@ -535,6 +535,12 @@ > .Xr sigvec 2 , > .Xr tcgetpgrp 3 , > .Xr tcsetpgrp 3 > +.Sh BUGS > +fcntl(F_GETLK) returns -1 in > +.Fa l_pid > +if the process holding a blocking lock previously locked the > +file desriptor by > +.Xr flock 2 . > .Sh HISTORY > The > .Fn fcntl > May be it will be good to put description of such behaviour of flock and fcntl to the manual page, not sure that it should be placed in the BUG section, but commiters should know where to put this sentence. In any way I agree that this PR can be closed. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message