Subject: Re: This should be the final cat(1) patch...
To: <>
From: David Laight <>
List: tech-userlevel
Date: 06/08/2002 20:18:12
On Sat, Jun 08, 2002 at 08:14:17PM +0200, Alan Barrett wrote:
> On Sat, 08 Jun 2002, Alan Barrett wrote:
> > Shells usually handle "cat >>foo" by opening the output file without
> > O_APPEND, and seeking to the end of file.
> Or so I thought.  Apparently my information is out of date.  NetBSD's
> /bin/sh and /bin/csh have always (since CVS revision 1.1 of the relevant
> source files) handled  ">>" redirection using O_APPEND.

But the 'alien' system you are running the build on might not.
I don't think the SVR4 'sh' behaves this way (hadn't used to),
Anyone fancy testing the solaris one?

As well as seeing log files 'corrupted' because the shell >>
didn't set O_APPEND.  I've also seen a system that failed to
get the 'write' and 'advance' parts of a normal (non append)
write atomic when two processes wrote using the same file
structure (eg parent and child).
This lead to both bits of data being written to the current
offset, followed by advancing the file pointer by the sum
of the lengths - leaving a short block of nulls in the file!
(This was a SMP bug...)


David Laight: