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 <mason@acheron.middleboro.ma.us>
List: tech-userlevel
Date: 06/07/2002 17:06:36
--1sPOHk9wyUr/csgM
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:
>=20
> exec >file
> echo line 1 | cat -l
> echo line 2 | cat -l
>=20
> 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=
ly
> 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?

--=20
Mason Loring Bliss   mason@acheron.middleboro.ma.us   Ewige Blumenkraft!
https://www.deadsexy.org/  awake ? sleep : random() & 2 ? dream : sleep;

--1sPOHk9wyUr/csgM
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (NetBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE9ASBcykMMY715wXIRArC5AKDwx/lORZsirXAvuM+tX+6JKo2HJwCfYkzn
DwQxfCoC8/krcetv/tWCk0s=
=4TOT
-----END PGP SIGNATURE-----

--1sPOHk9wyUr/csgM--