Thread View: gnu.utils.bug
1 messages
1 total messages
Started by trq
Sat, 03 Oct 1992 10:32
textutils 1.3: sort does not clean up after itself
Author: 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;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads