Large file problem with either grep and head

Solution Verified - Updated -

Issue

  • SIGPIPE is blocked and grep doesn't handle EPIPE so it prints error after error. In this case grep is ignoring SIGPIPE, grep doesn't exit, it keeps trying to write and keeps getting EPIPE and keeps printing an error, that is the unwanted behavior.

  • When SIGPIPE is not ignored, the default behavior is to terminate the process. So in the normal case, grep exits when getting SIGPIPE (because it isn't ignored) and never sees EPIPE so the question is why not handle EPIPE, maybe print one error, then exit with non-zero exit code in the case where SIGPIPE is blocked by the silly shell.

Environment

  • Red Hat Enterprise Linux 6

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content