Subject: Re: New cat(1) option (was: Re: Possible solution to toolchain/16963 - NBUILDJOBS/METALOG conflict)
To: None <email@example.com>
From: David Laight <firstname.lastname@example.org>
Date: 06/07/2002 21:19:52
On Fri, Jun 07, 2002 at 03:46:06PM -0400, Mason Loring Bliss wrote:
> On Fri, Jun 07, 2002 at 08:42:47AM +0200, Martin Husemann wrote:
> > > Since this works, locking stdout would seem to be a useful option for
> > > cat(1), perhaps.
> > Sounds good, and cat even has free option letters left ;-)
> It's the simplest solution of the lot, additionally.
> > Any hint from relevant standards?
> There's nothing that I can see. The only argument to cat noted in SuS2 is
> "-u". I would suggest "-l" for "lock".
> If no one objects to this, I'd like to apply the following patches to cat.
> I'll give it until Monday for objections, unless discussions ensues in the
> Along with this, I'd like to make basesrc/share/man/Makefile and
> basesrc/share/zoneinfo/Makefile use this to lock METALOG, so that builds
> with -j > 1 can complete. I'd also like to submit a pull-up request so that
> netbsd-1-6 can build with -j > 1. However, this would require having cat as
> a host tool, and I need to read more to see how to do that.
IMHO if you need a host tool, then a simple program that 'does the
required job' might be better than trying to get 'cat' built
as a host tool.
(cat does all sorts of tricks for efficiency - which aren't needed here)
> So, for starters, I'd like to simply add this useful cat
> functionality to the base system.
> Thanks in advance for constructive comments.
I think you need to ensure you remove the lock if (and only if)
you sucessfully obtain it.
echo line 1 | cat -l
echo line 2 | cat -l
without the unlock the second line probably blocks
(try this with your modified cat)
- if this is true you need to ensure that the unlock is done
on EVERY possible exit of the program..
I'm also not sure whether the kernel counts multiple lock
requests for the same 'file', or whether they block on each
other. (see flock(2) comments about children releasing
locks held by parents).
(I still think writing entire lines with O_APPEND set is
safer - especially on random OS)
David Laight: email@example.com