bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: O_TRUNC|O_APPEND not used for ">" redirection


From: Chet Ramey
Subject: Re: Fwd: O_TRUNC|O_APPEND not used for ">" redirection
Date: Fri, 14 Nov 2008 16:02:07 -0500
User-agent: Thunderbird 2.0.0.17 (Macintosh/20080914)

Andrew McGill wrote:


> Bash Version: 3.2
> Patch Level: 39
> Release Status: release
> 
> Description:
>       redirection using ">" creates a file descriptor without O_APPEND.  When
>       processes write simultanteously to this file, unnecessary data 
> corruption
>       occurs.

Output redirection has never used O_APPEND.  That's the difference between
`>' and `>>'.  If processes write simultaneously to any file, there is the
potential for overwriting and corruption depending on how the writes are
scheduled.  The usual fix is to adopt some ordering convention internal to
the application.

If you want to force append mode, you need to use `>>'.  That's why it
exists.

> Fix:
>       The fix is to include O_APPEND with O_CREAT when creating a file to
>       receive an output stream.  This has the minor side effect of making the 
>       output fd non-seekable.

I think you underestimate the impact of the "minor side effect".  The
status quo is the way things have existed for many years.  You don't know
the number of applications that expect to be able to seek in their output
stream if they detect it is a regular file.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]