Subject: Re: New cat(1) option (was: Re: Possible solution to toolchain/16963 - NBUILDJOBS/METALOG conflict)
To: David Laight , der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Mason Loring Bliss <>
List: tech-userlevel
Date: 06/07/2002 17:06:36
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Jun 07, 2002 at 09:19:52PM +0100, David Laight wrote:

> 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)

cat(1) *is* a rather short program, though. In the grand scheme of things,
it's not noticeably longer than either a cat(1)-wrapper or subset of cat(1)
that obeys locks and appends to a file.

> try:
> exec >file
> echo line 1 | cat -l
> echo line 2 | cat -l
> without the unlock the second line probably blocks
> (try this with your modified cat)

Works fine.

Once a process is finished, as I understand it, all its open file
descriptors go away and things associated with its state, like locks, also
go away. (I'm always open to correction, of course, but this certainly is
how the system behaves.)

> I'm also not sure whether the kernel counts multiple lock requests for the
> same 'file', or whether they block on each other.

They block, I believe, which is the desired result, unless I'm mis-
understanding you.

> (I still think writing entire lines with O_APPEND set is safer - especial=
> on random OS)

Safe... From what I can see, the only two things that modify METALOG are
the lines we're addressing directly here, and install(1), which explicitly
obeys advisory locks already.

On Fri, Jun 07, 2002 at 04:23:09PM -0400, der Mouse wrote:

> This is _supposed_ to be unnecessary; when the file descriptor is
> closed on exit, all locks on it are supposed to be released.

Are there any instances where this is not the case?

Mason Loring Bliss   Ewige Blumenkraft!  awake ? sleep : random() & 2 ? dream : sleep;

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.0.6 (NetBSD)
Comment: For info see