GNU bug report logs -
#11816
sort -o: error comes late if opening the outfile fails
Previous Next
Full log
View this message in rfc822 format
On 06/29/2012 12:54 PM, Bernhard Voelker wrote:
> If opening the output file for writing is not possible - e.g. because the user
> doesn't have sufficient privileges, then sort issues an error. The problem
> is that the whole - then useless - computation is already done.
>
> In the following little example, it took ~15s to sort the data,
> and then to realize that it can't write the result:
>
> $ time seq 1000000 | src/sort --random-sort -o /cantwritehere
> src/sort: open failed: /cantwritehere: Permission denied
>
> real 0m14.955s
> user 0m14.936s
> sys 0m0.042s
>
> I'd have expected sort to give the error immediately after startup
> instead of wasting time for sorting.
> Shouldn't sort open the outfile right at the beginning (unless in==out),
> or is this behavior required by some standard?
Hmm I think that would be an improvement.
Now if there was an issue with sorting (like running out of resources),
we'd prefer not to leave the empty output hanging around.
Also the in==out case, you'd like to check for write-ability too.
Both cases could be handled I think with something like:
if (access (outfile, W_OK) != 0 && errno != ENOENT)
error (...);
cheers,
Pádraig.
This bug report was last modified 12 years and 361 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.