<feed xmlns='http://www.w3.org/2005/Atom'>
<title>coreutils/tests/misc/sort-continue, branch v7.3</title>
<subtitle>Mirror of https://https.git.savannah.gnu.org/git/coreutils.git/
</subtitle>
<id>https://git.shady.money/coreutils/atom?h=v7.3</id>
<link rel='self' href='https://git.shady.money/coreutils/atom?h=v7.3'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/'/>
<updated>2009-03-18T20:44:45Z</updated>
<entry>
<title>tests: adjust sort-continue not to fail under valgrind</title>
<updated>2009-03-18T20:44:45Z</updated>
<author>
<name>Jim Meyering</name>
<email>meyering@redhat.com</email>
</author>
<published>2009-03-17T20:23:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=5b86dc69d7160b6422b02c8cfb909734275c2faa'/>
<id>urn:sha1:5b86dc69d7160b6422b02c8cfb909734275c2faa</id>
<content type='text'>
* tests/misc/sort-continue: Don't run cat inside fd-limited shell.
If sort fails to run in an fd-limited shell, skip the test.
</content>
</entry>
<entry>
<title>sort: handle fd exhaustion better when merging</title>
<updated>2009-03-18T20:44:37Z</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@CS.UCLA.EDU</email>
</author>
<published>2009-03-13T22:48:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/coreutils/commit/?id=8f7fae59727e0a050a4833705a6f7849ba2c4531'/>
<id>urn:sha1:8f7fae59727e0a050a4833705a6f7849ba2c4531</id>
<content type='text'>
This is an alternative to my 9 March patch labeled "Silently lower
nmerge; don't (sometimes incorrectly) range-check"
&lt;http://lists.gnu.org/archive/html/bug-coreutils/2009-03/msg00070.html&gt;.
It differs by not using 'dup' to probe for extra file descriptors;
instead, it simply calls 'open' (and 'pipe') to open files and pipes,
until one of these calls fails due to file descriptor exhaustion; it
then backs off by 1, does a merge with the files that it has opened,
and then retries with the (now-smaller) number of files.

This patch requires quite a few more changes to the source code than
the earlier patch, but it is in some sense "better" because it doesn't
need to call "dup" ahead of time in order to decide whether "open" or
"pipe" will fail.  Also, it's more robust in the case where "open" or
"pipe" fails with errno==EMFILE because some system-wide limit is
exhausted.

* src/sort.c (create_temp_file): New arg SURVIVE_FD_EXHAUSTION.
(stream_open): New function, containing guts of xfopen.
(xfopen): Use it.
(pipe_fork): Set errno on failure.
(maybe_create_temp): New function, containing guts of create_temp.
(create_temp): Use it.
(open_temp): Distinguish failures due to file descriptor exhaustion
from other failures, and on fd exhaustion return a notice to caller
rather than dying.  Don't test execlp's return value; when it returns,
it *always* returns -1.
(open_input_files): New function.
(mergefps): New arg FPS. It's now the caller's responsibility to open
the input and output files.  All callers changed.
(mergefiles): New function.
(avoid_trashing_input, merge): Handle the case where a single merge
can't merge as much as we wanted due to file descriptor exhaustion, by
merging as much as we can and then retrying.
* tests/Makefile.am (TESTS): Add misc/sort-continue.
* tests/misc/sort-continue: New file.
* THANKS: Add Glen Lenker and Matt Pham who coauthored this patch.
</content>
</entry>
</feed>
