From owner-freebsd-arch@FreeBSD.ORG Mon Jun 26 04:07:57 2006 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AD8FB16A403 for ; Mon, 26 Jun 2006 04:07:57 +0000 (UTC) (envelope-from andrew@areilly.bpc-users.org) Received: from omta04ps.mx.bigpond.com (omta04ps.mx.bigpond.com [144.140.83.156]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8216F43D6E for ; Mon, 26 Jun 2006 04:07:51 +0000 (GMT) (envelope-from andrew@areilly.bpc-users.org) Received: from areilly.bpc-users.org ([141.168.7.22]) by omta04ps.mx.bigpond.com with ESMTP id <20060626040750.QUTS22738.omta04ps.mx.bigpond.com@areilly.bpc-users.org> for ; Mon, 26 Jun 2006 04:07:50 +0000 Received: (qmail 30696 invoked by uid 501); 26 Jun 2006 04:07:54 -0000 Date: Mon, 26 Jun 2006 14:07:54 +1000 From: Andrew Reilly To: freebsd-arch@freebsd.org Message-ID: <20060626040754.GA30475@duncan.reilly.home> References: <20060625011746.GC81052@duncan.reilly.home> <20060625214021.GJ82074@funkthat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060625214021.GJ82074@funkthat.com> User-Agent: Mutt/1.4.2.1i Subject: Re: What's up with our stdout? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jun 2006 04:07:57 -0000 On Sun, Jun 25, 2006 at 02:40:21PM -0700, John-Mark Gurney wrote: > Andrew Reilly wrote this message on Sun, Jun 25, 2006 at 11:17 +1000: > > One interesting problem that I found yesterday was that NetBSD > > have added a "-l" option to cat, which is supposed to apply an > > exclusive advisory lock with fcntl to the the output file, and > > wait until that succeeds: > > http://netbsd.gw.com/cgi-bin/man-cgi?cat++NetBSD-current > > That seems like a pretty useful idea, > > because it means that you can have parallel make jobs all > > contributing to a log file or the like (with cat -l >> foo.log), > > without getting in eachothers' way. > > Why not use: > lockf -k foo.log cat >> foo.log > > Should do the same thing... Not only should it, I've just checked and discovered that it does. So I'll make up the appropriate tweak to NetBSD's Makefiles, and suggest on the mailing lists that they think about incorporating it, as it's ostensibly a more general and useful way to do it. This does make me wonder, though, why this _does_ work, given Bruce's explanation of why the nbcat code doesn't... Hmm. lockf.c uses open(...,|O_EXLOCK), rather than fcntl(). Any particular reason why that should behave differently? Cheers, -- Andrew