Bug 753723

Summary: Piping into grep fails with EPIPE
Product: [openSUSE] openSUSE 12.2 Reporter: Manuel Stol <ManuelStol>
Component: BasesystemAssignee: E-mail List <bnc-team-screening>
Status: RESOLVED INVALID QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P5 - None    
Version: Factory   
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE 12.2   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: strace of (echo "foobar" | grep "foo")
strace of (echo "foobar" | sed "s/foo/XXX/")

Description Manuel Stol 2012-03-23 03:27:14 UTC
Created attachment 482857 [details]
strace of (echo "foobar" | grep "foo")

User-Agent:       Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) konqueror/4.8.1 Safari/534.34

Piping stdout into grep fails with an EPIPE.

Reproducible: Always

Steps to Reproduce:
1. Open a terminal (xterm, konsole) as a normal user.
2. type:  echo "foobar" | grep "foo"

Actual Results:  
No output to stdout due to an EPIPE error.

Expected Results:  
The lines that match the grep pattern.

- This doesn't happen when opening a terminal as root nor
   when switching to root with 'su -'.
- Neither grep nor egrep work.
- When replacing grep with sed, piping works as expected.
- Tried it with konsole, xterm and linux 32-bit terminal.
- I've been updating my system since openSUSE 11.4.
- I've re-intalled the grep rpm.
- YaST does not start on a 64bit system, as grep is used in
  /usr/lib/YaST2/bin/yast2-funcs
  Workaround: Start YaST with '--qt' or '--gtk'.
Comment 1 Manuel Stol 2012-03-23 03:29:03 UTC
Created attachment 482858 [details]
strace of (echo "foobar" | sed "s/foo/XXX/")
Comment 2 Manuel Stol 2012-03-25 10:23:29 UTC
- I'm using 'secure' permissions.
  PERMISSION_SECURITY="secure local" in '/etc/sysconfig/security'
  As POLKIT_DEFAULT_PRIVS is unset, PolicyKit uses 'restrictive' privilege settings.
Comment 3 Manuel Stol 2012-04-10 13:02:47 UTC
Changing the file permissions or PolicyKit privilege settings did not help.
Comment 4 Manuel Stol 2012-04-10 13:06:46 UTC
When I add a new user, this new user does not have the 'piping to grep' problem.

So my user settings must be borked.

Can anyone tell me how to debug this?
Comment 5 Manuel Stol 2012-04-10 18:55:08 UTC
Resolved.

For over a decade I used the following in my profile:
"
# Do not grep devices!  The keyboard becomes unusable when grepping on it.
export GREP_OPTIONS="--devices=skip"
"

It looks that in the latest Linux kernel piping is/uses a FIFO device.