From owner-freebsd-stable Sun Jun 23 5:47:50 2002 Delivered-To: freebsd-stable@freebsd.org Received: from sea-incorporated.com (caribbean.sea-incorporated.com [209.74.10.130]) by hub.freebsd.org (Postfix) with ESMTP id AAEF937B403 for ; Sun, 23 Jun 2002 05:47:39 -0700 (PDT) Received: from sea-incorporated.com (localhost [127.0.0.1]) by sea-incorporated.com (8.12.3/8.12.3) with ESMTP id g5NCk00t029747; Sun, 23 Jun 2002 08:46:00 -0400 (EDT) (envelope-from geoff@sea-incorporated.com) Received: from localhost (geoff@localhost) by sea-incorporated.com (8.12.3/8.12.3/Submit) with ESMTP id g5NCjxfB029744; Sun, 23 Jun 2002 08:45:59 -0400 (EDT) Date: Sun, 23 Jun 2002 08:45:58 -0400 (EDT) From: "Geoffrey C. Speicher" To: Paul Herman Cc: "Matthew D. Fuller" , , Matt Simerson Subject: Re: bug in pw, -STABLE [patch] In-Reply-To: <20020623000216.E37393-100000@mammoth.eat.frenchfries.net> Message-ID: <20020623083510.K29729-100000@sea-incorporated.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 23 Jun 2002, Paul Herman wrote: > On Sat, 22 Jun 2002, Geoffrey C. Speicher wrote: > > > DESCRIPTION > > pid_begin() will check for existence of the pid file named > > _path_, and if it exists, determine whether the process whose > > pid is contained therein is still running. > > > > [...] > > That's nice and all, but you really are trying to solve the wrong > problem here. Remember, you want to lock a particular file and not > an entire process. (Think: concurrent pw(8)s with different -V > directories.) > > Keep it simple. Do what you mean. If you want to make changes to > /etc/master.passwd then open(2) /etc/master.passwd with O_EXLOCK. As Matt Fuller already pointed out in a follow-up, that brings us back to where we were when we started, and it doesn't work for this application, since master.passwd disappears and reappears before we're done. Hence the use of a pid file as a mutex. You raise a good point about concurrent pw(8)s with different -V parameters, and I would think that the solution would be either to use a different pid file for each -V, or to not worry about it for pw(8) and have concurrent instances sometimes block briefly when it's not necessary. Geoff To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message