# [PATCH] diff-tree: stop on broken output pipe

5 messages from 2006-01-02 to 2006-01-07. Participants: Johannes Schindelin, Andreas Ericsson, Junio C Hamano.
Thread: https://gitlist.dev/t/2952

## Johannes Schindelin, 2006-01-02 00:17

Subject: [PATCH] diff-tree: stop on broken output pipe
Message-ID: <Pine.LNX.4.63.0601020116020.11331@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0601020116020.11331%40wbgn013.biozentrum.uni-wuerzburg.de

```

---

	Without this, on my iBook git-whatchanged keeps running when I 
	quit "less". I have to interrupt the process a second time. No
	idea why it works on Linux.

 diff-tree.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

a3ff3aa99f1cc7d1e59563fbf22fed8a4f3f2d24
diff --git a/diff-tree.c b/diff-tree.c
index efa2b94..c06ccd3 100644
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -25,8 +25,9 @@ static int call_diff_flush(void)
 		return 0;
 	}
 	if (header) {
-		if (!no_commit_id)
-			printf("%s%c", header, diff_options.line_termination);
+		if (!no_commit_id && printf("%s%c", header,
+				diff_options.line_termination) < 0)
+			die("broken output pipe");
 		header = NULL;
 	}
 	diff_flush(&diff_options);
-- 
1.0.GIT

```

## Andreas Ericsson, 2006-01-02 01:21

Subject: Re: [PATCH] diff-tree: stop on broken output pipe
Message-ID: <43B88013.3020904@op5.se>
URL: https://gitlist.dev/e/43B88013.3020904%40op5.se
In-Reply-To: <Pine.LNX.4.63.0601020116020.11331@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin wrote:
> ---
> 
> 	Without this, on my iBook git-whatchanged keeps running when I 
> 	quit "less". I have to interrupt the process a second time. No
> 	idea why it works on Linux.
> 

On Linux the sending end dies when it catches SIGPIPE. I would have 
thought that should happen on OSX too. What shell are you running?

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Johannes Schindelin, 2006-01-02 11:01

Subject: Re: [PATCH] diff-tree: stop on broken output pipe
Message-ID: <Pine.LNX.4.63.0601021159170.24000@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0601021159170.24000%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <43B88013.3020904@op5.se>

```
Hi,

On Mon, 2 Jan 2006, Andreas Ericsson wrote:

> Johannes Schindelin wrote:
> > ---
> > 
> > 	Without this, on my iBook git-whatchanged keeps running when I 	quit
> > "less". I have to interrupt the process a second time. No
> > 	idea why it works on Linux.
> > 
> 
> On Linux the sending end dies when it catches SIGPIPE. I would have thought
> that should happen on OSX too. What shell are you running?

Why, bash 2.05a0(1)-release (powerpc-app,e-darwin6.0). Is there a way to 
turn off SIGPIPEs? Could be turned off by mistake here...

Ciao,
Dscho

```

## Junio C Hamano, 2006-01-06 22:36

Subject: Re: [PATCH] diff-tree: stop on broken output pipe
Message-ID: <7vhd8ht24d.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vhd8ht24d.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0601020116020.11331@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> 	Without this, on my iBook git-whatchanged keeps running when I 
> 	quit "less". I have to interrupt the process a second time. No
> 	idea why it works on Linux.
>
> -		if (!no_commit_id)
> -			printf("%s%c", header, diff_options.line_termination);
> +		if (!no_commit_id && printf("%s%c", header,
> +				diff_options.line_termination) < 0)
> +			die("broken output pipe");
>  		header = NULL;

There are tons of output other than this printf() and catching
an output error only on this one and assuming that is a broken
pipe somehow feels doubly wrong to me.

```

## Johannes Schindelin, 2006-01-07 00:41

Subject: Re: [PATCH] diff-tree: stop on broken output pipe
Message-ID: <Pine.LNX.4.63.0601070134010.30029@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0601070134010.30029%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <7vhd8ht24d.fsf@assigned-by-dhcp.cox.net>

```
Hi,

On Fri, 6 Jan 2006, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > 	Without this, on my iBook git-whatchanged keeps running when I 
> > 	quit "less". I have to interrupt the process a second time. No
> > 	idea why it works on Linux.
> >
> > -		if (!no_commit_id)
> > -			printf("%s%c", header, diff_options.line_termination);
> > +		if (!no_commit_id && printf("%s%c", header,
> > +				diff_options.line_termination) < 0)
> > +			die("broken output pipe");
> >  		header = NULL;
> 
> There are tons of output other than this printf() and catching
> an output error only on this one and assuming that is a broken
> pipe somehow feels doubly wrong to me.

Welcome back! Hope you had a good time, and the fish tasted fine.

There really are tons of printf(), but

- I did not want to be invasive,
- if one printf() fails, the next will, too (probably), and
- the problem occurs only on macosx here.

Maybe it is not correct to assume that the output pipe is broken, but it 
is an error to keep going when printf() fails. So I picked one printf() 
which is called regularly.

Andreas said that a SIGPIPE should be thrown, and bash should kill the 
script. I have not found out why my bash doesn't. Until I do, I will have 
this patch in my local git (and a similar patch in git-rev-list). It just 
is plain annoying when git-whatchanged (the git script I use most often) 
hangs there, burning cycles.

Ciao,
Dscho

```
