bug-coreutils
[Top][All Lists]
Advanced

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

Re: merge sort temporary files


From: Paul Eggert
Subject: Re: merge sort temporary files
Date: Fri, 14 May 2004 09:08:46 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

"Charlie Gordon" <address@hidden> writes:

> sort should first try to unlink the output file before opening it in
> "w" mode.  cat would keep reading the old file while sort writes to
> a new file with the same name.

Sorry, that wouldn't work, for two reasons.  First, the two processes
are running in parallel so it doesn't solve the problem in general.
For example, in:

cat F G | sort -m -o G - H

if "sort" doesn't make a copy of all its input first, it'd quite
possible for sort to unlink G and open G for writing before cat opens
G for reading.

Second, POSIX doesn't allow it.  With a few exceptions (and this isn't
one of them), POSIX requires that output files be opened only with
"open"; you're not allowed to unlink first.  Here are the general rules:

<http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap01.html#tag_01_07_01_04>




reply via email to

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