Bug 24104 - zgrep should catch SIGPIPE
zgrep should catch SIGPIPE
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: gzip (Show other bugs)
7.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Trond Eivind Glomsrxd
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-01-16 07:39 EST by Karsten Hopp
Modified: 2007-04-18 12:30 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-01-30 19:16:23 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Karsten Hopp 2001-01-16 07:39:16 EST
Try this:
zgrep .so /usr/share/man/man1/*gz | less
and press 'q' after the first page and you'll see what I mean
Comment 1 Trond Eivind Glomsrxd 2001-01-17 15:47:16 EST
I agree that it's a problem... patch? :)
Comment 2 Karsten Hopp 2001-01-17 20:14:02 EST
adding a line with 'trap break SIGPIPE' before the for loop,
an 'echo' at the end of the loop and a line 'trap - SIGPIPE'
seems to work here, but I can't say if this breaks anything else.
The echo is needed or the trap won't be executed until the for loop
is finished.
Comment 3 Trond Eivind Glomsrxd 2001-01-30 15:27:34 EST
I can't get that working... exactly how does your script look?
Comment 4 Karsten Hopp 2001-01-30 19:16:19 EST
Only the last few lines of zgrep:
res=0
trap break SIGPIPE
for i do
  if test $list -eq 1; then
    gzip -cdfq "$i" | $grep $opt "$pat" > /dev/null && echo $i
    r=$?
  elif test $# -eq 1 -o $silent -eq 1; then
    gzip -cdfq "$i" | $grep $opt "$pat"
    r=$?
  else
    gzip -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${i}:|"
    r=$?
  fi
  test "$r" -ne 0 && res="$r"
  echo
done
trap - SIGPIPE
exit $res
Comment 5 Trond Eivind Glomsrxd 2001-01-30 20:32:46 EST
Fixed in gzip-1.3-11... I added the echo after the loop. Doh.

Note You need to log in before you can comment on or make changes to this bug.