public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Paul Jackson <pj@sgi•com>
To: Petr Baudis <pasky@ucw•cz>
Cc: rene.scharfe@lsrfire•ath.cx, torvalds@osdl•org, git@vger•kernel.org
Subject: Re: How to get bash to shut up about SIGPIPE?
Date: Mon, 2 May 2005 18:44:24 -0700	[thread overview]
Message-ID: <20050502184424.7cb7f2a4.pj@sgi.com> (raw)
In-Reply-To: <20050502231743.GL20818@pasky.ji.cz>

> Could you elaborate on how exactly is it supposed to help?

The key code is in bash/jobs.c.

If you have a bash while or for loop feeding a pipe that shuts down
while the loop is still running commands that try to write the pipe
(perhaps you were pipe'ing to "head -1", and it exit'd, having read its
one line), then the next command to attempt to write that pipe will die,
and the bash instance that is handling that loop (and forked that
command that just died) will notice the command died with a SIGPIPE
signal.

At this point, one of three possible things happens:

 1) If your bash is compiled with DONT_REPORT_SIGPIPE defined, then
    that bash instance quietly leaves.  The concensus around here
    is that is "good(tm)."

 2) If not so compiled, then:

	2a) If you set a trap on SIGPIPE in that shell, it prints:

		fprintf (stderr, "%s", j_strsignal (termsig));

	2b) Else if you did not trap SIGPIPE, it prints:

		fprintf (stderr, "%s: line %d: ", get_name_for_error (),
				(line_number == 0) ? 1 : line_number);
		pretty_print_job (job, JLIST_NONINTERACTIVE, stderr);


The pretty_print_job() in (2b) can be a multi-line confusion.

Sample output for (2a):

	Broken pipe

Sample output in simple one line case for (2b):

	foo: line 2: 11663 Broken pipe             cat /etc/termcap

A couple of others are reporting different behaviour than what I report
above - including Linus.

So it is almost certain that I don't understand all I know about this.

What behaviour do you see?

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@engr•sgi.com> 1.650.933.1373, 1.925.600.0401

      reply	other threads:[~2005-05-03  1:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-28 18:28 How to get bash to shut up about SIGPIPE? Linus Torvalds
2005-04-28 19:03 ` Rene Scharfe
2005-04-28 19:21   ` Linus Torvalds
2005-04-28 20:13     ` Rene Scharfe
2005-04-28 20:27     ` Ryan Anderson
2005-04-28 20:47       ` Linus Torvalds
2005-05-01 12:07       ` Herbert Xu
2005-05-01 15:51         ` David A. Wheeler
2005-05-02 16:10           ` Paul Jackson
2005-05-04  2:30             ` David A. Wheeler
2005-05-04  2:50               ` Linus Torvalds
2005-05-04  8:26                 ` Herbert Xu
2005-04-28 21:31 ` Edgar Toernig
2005-04-28 22:16   ` Linus Torvalds
2005-04-29  1:00 ` Joshua T. Corbin
2005-04-30  0:22 ` Paul Jackson
2005-04-30  2:59   ` Linus Torvalds
2005-04-30  6:29     ` Paul Jackson
2005-04-30 11:04       ` Rene Scharfe
2005-05-02 22:17         ` Paul Jackson
2005-05-02 23:17         ` Petr Baudis
2005-05-03  1:44           ` Paul Jackson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050502184424.7cb7f2a4.pj@sgi.com \
    --to=pj@sgi$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=pasky@ucw$(echo .)cz \
    --cc=rene.scharfe@lsrfire$(echo .)ath.cx \
    --cc=torvalds@osdl$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox