diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/misc/sort-merge-fdlimit | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/misc/sort-merge-fdlimit b/tests/misc/sort-merge-fdlimit index 1ed50952f..b0ab71cec 100755 --- a/tests/misc/sort-merge-fdlimit +++ b/tests/misc/sort-merge-fdlimit @@ -50,4 +50,24 @@ for randsource in '' --random-source=some-data; do || ! grep "open failed" err/merge-random-err) || fail=1 done +# 'sort -m' should work in a limited file descriptor +# environment when the output is repeatedly one of its inputs. +# In coreutils 8.7 and earlier, 'sort' would dump core on this test. +# +# This test uses 'exec' to redirect file descriptors rather than +# ordinary redirection on the 'sort' command. This is intended to +# work around bugs in OpenBSD /bin/sh, and some other sh variants, +# that squirrel away file descriptors before closing them; see +# <http://lists.gnu.org/archive/html/bug-tar/2010-10/msg00075.html>. +# This test finds the bug only with shells that do not close FDs on +# exec, and will miss the bug (if present) on other shells, but it's +# not easy to fix this without running afoul of the OpenBSD-like sh bugs. +(seq 6 && echo 6) >exp || fail=1 +echo 6 >out || fail=1 +(exec 3<&- 4<&- 5<&- 6</dev/null 7<&6 8<&6 9<&6 && + ulimit -n 10 && + sort -n -m --batch-size=7 -o out out in/1 in/2 in/3 in/4 in/5 out +) && +compare out exp || fail=1 + Exit $fail |