Article View: gnu.utils.bug
Article #997textutils 1.3: sort does not clean up after itself
From: trq
Date: Sat, 03 Oct 1992 10:32
Date: Sat, 03 Oct 1992 10:32
65 lines
2866 bytes
2866 bytes
Sort does not clean up after itself if it gets a SIGPIPE. This can be
demonstrated by compiling this program:
#include <stdio.h>
main()
{
int i;
for(i = 0; i < 100000; i++)
printf("%d\n", i);
}
After running it and directing the output to a file "tst.sort", the
command "sort tst.sort | more", followed by a "q" to exit more will
leave files around in /tmp as evidenced by the command:
ls -l /tmp/s*
-rw-r--r-- 1 trq staff 87194 Oct 3 11:11 /tmp/sort1823800001
-rw-r--r-- 1 trq staff 98304 Oct 3 11:11 /tmp/sort1823800002
-rw-r--r-- 1 trq staff 98304 Oct 3 11:11 /tmp/sort1823800003
-rw-r--r-- 1 trq staff 98304 Oct 3 11:11 /tmp/sort1823800004
-rw-r--r-- 1 trq staff 98304 Oct 3 11:11 /tmp/sort1823800005
-rw-r--r-- 1 trq staff 43878 Oct 3 11:11 /tmp/sort1823800006
-rw-r--r-- 1 trq staff 64602 Oct 3 11:11 /tmp/sort1823800007
This is for sort in textutils-1.3 compiled with gcc 2.2.2 on a Sun
Sparcstation ELC running SunOs 4.1.1. Config.status reads:
DEFS=" -DSTDC_HEADERS -DHAVE_UNISTD_H -DSTRERROR_MISSING"
LIBS="-lmalloc"
CC="gcc"
INSTALL="/bin/install -c"
INSTALLDATA="/bin/install -c -m 644"
RANLIB="ranlib "
LIBOBJS=" memcmp.o stpcpy.o"
ALLOCA=""
The problem is that SIGPIPE is not caught and handled. A sample patch
to fix this is below.
Tom Quinn Theoretical Physics, University of Oxford
Internet: trq@dionysos.thphys.ox.ac.uk
JANET: trq@uk.ac.ox.astro
Phone: 44-865-273956
===================================================================
RCS file: RCS/sort.c,v
retrieving revision 1.1
diff -c -r1.1 sort.c
*** 1.1 1992/10/03 10:11:49
--- sort.c 1992/10/03 10:12:36
***************
*** 1456,1466 ****
--- 1456,1471 ----
sigaction (SIGHUP, NULL, &oldact);
if (oldact.sa_handler != SIG_IGN)
sigaction (SIGHUP, &newact, NULL);
+ sigaction (SIGPIPE, NULL, &oldact);
+ if (oldact.sa_handler != SIG_IGN)
+ sigaction (SIGPIPE, &newact, NULL);
#else /* !_POSIX_VERSION */
if (signal (SIGINT, SIG_IGN) != SIG_IGN)
signal (SIGINT, sighandler);
if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
signal (SIGHUP, sighandler);
+ if (signal (SIGPIPE, SIG_IGN) != SIG_IGN)
+ signal (SIGPIPE, sighandler);
#endif /* _POSIX_VERSION */
gkey.sword = gkey.eword = -1;
Technical Details
Message-ID:
<9210031032.AA14234@thphys.ox.ac.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!dionysos.thphys.ox.ac.uk!trqShow Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!dionysos.thphys.ox.ac.uk!trq From: trq@dionysos.thphys.ox.ac.uk Subject: textutils 1.3: sort does not clean up after itself Message-ID: <9210031032.AA14234@thphys.ox.ac.uk> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Sat, 3 Oct 1992 10:32:40 GMT Approved: bug-gnu-utils@prep.ai.mit.edu Lines: 66