"Charlie Gordon" <[EMAIL PROTECTED]> 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>


_______________________________________________
Bug-coreutils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to