bug-coreutils
[Top][All Lists]
Advanced

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

bug#11816: sort -o: error comes late if opening the outfile fails


From: Pádraig Brady
Subject: bug#11816: sort -o: error comes late if opening the outfile fails
Date: Fri, 29 Jun 2012 13:55:59 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

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.





reply via email to

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