Subject: sort(1) opens too many files
To: None <>
From: Dave Huang <>
List: current-users
Date: 04/05/2001 04:12:24
Okay, so we've switched from GNU sort to BSD sort... but it seems to
want to open _way_ too many file descriptors (by calling mkstemp()):

yerfable /usr/src# ls -l .glimpse_tmpi2
-rw-------  1 root  wheel  15510668 Apr  5 03:30 .glimpse_tmpi2
yerfable /usr/src# limit descriptors 195
yerfable /usr/src# sort -T /usr/src /usr/src/.glimpse_tmpi2 > /usr/src/.glimpse_tmpo2
sort: ftmp: mkstemp("/usr/src/sort.014523ci"): Too many open files
yerfable /usr/src# limit descriptors 200
yerfable /usr/src# sort -T /usr/src /usr/src/.glimpse_tmpi2 > /usr/src/.glimpse_tmpo2
yerfable /usr/src#

I really don't think sort needs to open 200 temporary files to do its
job :)

And it even has problems with pretty small files:
yerfable ~> ls -l /usr/share/dict/words
-r--r--r--  2 root  wheel  2486864 Jan 14 23:24 /usr/share/dict/words
yerfable ~> limit descriptors 127
yerfable ~> sort /usr/share/dict/words > /dev/null
sort: ftmp: mkstemp("/usr/tmp/sort.014589iy"): Too many open files
yerfable ~> limit descriptors 128
yerfable ~> sort /usr/share/dict/words > /dev/null
yerfable ~>

Is there a missing fclose() someplace?
Name: Dave Huang         |  Mammal, mammal / their names are called /
INet: |  they raise a paw / the bat, the cat /
FurryMUCK: Dahan         |  dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 25 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++