Re: git fails with a broken pipe when one quits the pager

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 31.01.21 um 21:49 schrieb Ævar Arnfjörð Bjarmason:
> On Sun, Jan 31 2021, Vincent Lefevre wrote:
>> On 2021-01-31 02:47:59 +0100, Ævar Arnfjörð Bjarmason wrote:
>>> On Fri, Jan 15 2021, Vincent Lefevre wrote:
>>>> And of course, I don't want to hide error messages by default, because
>>>> this would hide *real* errors.
>>>
>>> Isn't the solution to this that your shell stops reporting failures due
>>> to SIGPIPE in such a prominent way then?
>>
>> No! I want to be warned about real SIGPIPEs.
> 
> Not being able to write "git log" output is a real SIGPIPE.

When Git is talking to a pager *and* it knows about it because has
started it itself, SIGPIPE is just a nuisance, not a useful behavior.

Guess why `git log` works on Windows when the pager is quit early, where
we do not have SIGPIPE? Because write errors are checked in sufficiently
many places.

I propose to do just this:

diff --git a/pager.c b/pager.c
index ee435de675..9fcc36425f 100644
--- a/pager.c
+++ b/pager.c
@@ -138,6 +138,7 @@ void setup_pager(void)
 
 	/* this makes sure that the parent terminates after the pager */
 	sigchain_push_common(wait_for_pager_signal);
+	sigchain_push(SIGPIPE, SIG_IGN);
 	atexit(wait_for_pager_atexit);
 }
 
diff --git a/run-command.c b/run-command.c
index ea4d0fb4b1..c0041413b5 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1165,10 +1165,6 @@ void check_pipe(int err)
 	if (err == EPIPE) {
 		if (in_async())
 			async_exit(141);
-
-		signal(SIGPIPE, SIG_DFL);
-		raise(SIGPIPE);
-		/* Should never happen, but just in case... */
 		exit(141);
 	}
 }



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux