Bug 24104

Summary: zgrep should catch SIGPIPE
Product: [Retired] Red Hat Linux Reporter: Karsten Hopp <karsten>
Component: gzipAssignee: Trond Eivind Glomsrxd <teg>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-01-31 00:16:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Karsten Hopp 2001-01-16 12:39:16 UTC
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 20:47:16 UTC
I agree that it's a problem... patch? :)

Comment 2 Karsten Hopp 2001-01-18 01:14:02 UTC
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 20:27:34 UTC
I can't get that working... exactly how does your script look?

Comment 4 Karsten Hopp 2001-01-31 00:16:19 UTC
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-31 01:32:46 UTC
Fixed in gzip-1.3-11... I added the echo after the loop. Doh.