* [PATCH v2] diff-highlight: exit when a pipe is broken
@ 2014-11-04 20:01 John Szakmeister
2014-11-04 20:09 ` Jeff King
0 siblings, 1 reply; 3+ messages in thread
From: John Szakmeister @ 2014-11-04 20:01 UTC (permalink / raw)
To: git; +Cc: John Szakmeister, peff
While using diff-highlight with other tools, I have discovered that Python
ignores SIGPIPE by default. Unfortunately, this also means that tools
attempting to launch a pager under Python--and don't realize this is
happening--means that the subprocess inherits this setting. In this case, it
means diff-highlight will be launched with SIGPIPE being ignored. Let's work
with those broken scripts by restoring the default SIGPIPE handler.
Signed-off-by: John Szakmeister <john@szakmeister.net>
---
Incorporates feedback from Jeff King and now we just restore the default signal
handler using the correct case of 'DEFAULT'.
contrib/diff-highlight/diff-highlight | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/contrib/diff-highlight/diff-highlight b/contrib/diff-highlight/diff-highlight
index c4404d4..69a652e 100755
--- a/contrib/diff-highlight/diff-highlight
+++ b/contrib/diff-highlight/diff-highlight
@@ -14,6 +14,10 @@ my @removed;
my @added;
my $in_hunk;
+# Some scripts may not realize that SIGPIPE is being ignored when launching the
+# pager--for instance scripts written in Python.
+$SIG{PIPE} = 'DEFAULT';
+
while (<>) {
if (!$in_hunk) {
print;
--
2.0.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] diff-highlight: exit when a pipe is broken
2014-11-04 20:01 [PATCH v2] diff-highlight: exit when a pipe is broken John Szakmeister
@ 2014-11-04 20:09 ` Jeff King
2014-11-04 20:52 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2014-11-04 20:09 UTC (permalink / raw)
To: John Szakmeister; +Cc: git
On Tue, Nov 04, 2014 at 03:01:12PM -0500, John Szakmeister wrote:
> While using diff-highlight with other tools, I have discovered that Python
> ignores SIGPIPE by default. Unfortunately, this also means that tools
> attempting to launch a pager under Python--and don't realize this is
> happening--means that the subprocess inherits this setting. In this case, it
> means diff-highlight will be launched with SIGPIPE being ignored. Let's work
> with those broken scripts by restoring the default SIGPIPE handler.
>
> Signed-off-by: John Szakmeister <john@szakmeister.net>
> ---
> Incorporates feedback from Jeff King and now we just restore the default signal
> handler using the correct case of 'DEFAULT'.
Thanks, this version looks much simpler. :)
Acked-by: Jeff King <peff@peff.net>
-Peff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] diff-highlight: exit when a pipe is broken
2014-11-04 20:09 ` Jeff King
@ 2014-11-04 20:52 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2014-11-04 20:52 UTC (permalink / raw)
To: Jeff King; +Cc: John Szakmeister, git
Jeff King <peff@peff.net> writes:
> On Tue, Nov 04, 2014 at 03:01:12PM -0500, John Szakmeister wrote:
>
>> While using diff-highlight with other tools, I have discovered that Python
>> ignores SIGPIPE by default. Unfortunately, this also means that tools
>> attempting to launch a pager under Python--and don't realize this is
>> happening--means that the subprocess inherits this setting. In this case, it
>> means diff-highlight will be launched with SIGPIPE being ignored. Let's work
>> with those broken scripts by restoring the default SIGPIPE handler.
>>
>> Signed-off-by: John Szakmeister <john@szakmeister.net>
>> ---
>> Incorporates feedback from Jeff King and now we just restore the default signal
>> handler using the correct case of 'DEFAULT'.
>
> Thanks, this version looks much simpler. :)
>
> Acked-by: Jeff King <peff@peff.net>
Thanks, both. The patch looks good. Will queue.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-04 20:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-04 20:01 [PATCH v2] diff-highlight: exit when a pipe is broken John Szakmeister
2014-11-04 20:09 ` Jeff King
2014-11-04 20:52 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).