From owner-freebsd-questions Fri May 7 0:41: 5 1999 Delivered-To: freebsd-questions@freebsd.org Received: from implode.root.com (root.com [209.102.106.178]) by hub.freebsd.org (Postfix) with ESMTP id E0B7615D74; Fri, 7 May 1999 00:40:59 -0700 (PDT) (envelope-from root@implode.root.com) Received: from implode.root.com (localhost [127.0.0.1]) by implode.root.com (8.8.8/8.8.5) with ESMTP id AAA17669; Fri, 7 May 1999 00:37:36 -0700 (PDT) Message-Id: <199905070737.AAA17669@implode.root.com> To: "Sameer R. Manek" Cc: freebsd-questions@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: bug with lockf(3)? In-reply-to: Your message of "Thu, 06 May 1999 22:31:35 PDT." From: David Greenman Reply-To: dg@root.com Date: Fri, 07 May 1999 00:37:36 -0700 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >I had posted this originally to freebsd-stable but didn't get any response >from that list. > >On freebsd 3-1-stable I'm not sure if this is a bug or my misinterpetation >of how lockf() works. But here's the situation. > >Given 2 processes A and B, both with open file descriptors to a file, >using open ("file.txt",O_RDWR) >A calls lockf (fd,F_LOCK,0) and proceeds to read/write to file >while file is still locked....including using lseek to jump to the >begining of the file >B calls lockf (fd,F_LOCK,0) and enters blocked state >A calls lockf (fd,F_ULOCK,0) >B is still in blocked state, until A exit(3)s. > >According to the man page: > F_LOCK and F_TLOCK requests differ only by the action taken if the >section is not available. F_LOCK blocks the calling process until the >section is available. F_TLOCK makes the function fail if the section is >already locked by another process. Does the same problem occur when using flock()? -DG David Greenman Co-founder/Principal Architect, The FreeBSD Project - http://www.freebsd.org Creator of high-performance Internet servers - http://www.terasolutions.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message