{"thread":{"id":"37877","subject":"[PATCH v2] diff-highlight: exit when a pipe is broken","startedAt":"2014-11-04T20:01:12Z","lastAt":"2014-11-04T20:52:57Z","messageCount":3,"participants":["John Szakmeister","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"251380","messageId":"1415131272-89441-1-git-send-email-john@szakmeister.net","threadId":"37877","inReplyTo":null,"subject":"[PATCH v2] diff-highlight: exit when a pipe is broken","fromName":"John Szakmeister","fromEmail":"john@szakmeister.net","sentAt":"2014-11-04T20:01:12Z","receivedAt":"2014-11-04T20:01:12Z","isPatch":true,"sender":{"key":"john@szakmeister.net","avatar":"https://avatars.githubusercontent.com/u/448087?v=4"},"body":"While using diff-highlight with other tools, I have discovered that Python\nignores SIGPIPE by default.  Unfortunately, this also means that tools\nattempting to launch a pager under Python--and don't realize this is\nhappening--means that the subprocess inherits this setting.  In this case, it\nmeans diff-highlight will be launched with SIGPIPE being ignored.  Let's work\nwith those broken scripts by restoring the default SIGPIPE handler.\n\nSigned-off-by: John Szakmeister <john@szakmeister.net>\n---\nIncorporates feedback from Jeff King and now we just restore the default signal\nhandler using the correct case of 'DEFAULT'.\n\n contrib/diff-highlight/diff-highlight | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/contrib/diff-highlight/diff-highlight b/contrib/diff-highlight/diff-highlight\nindex c4404d4..69a652e 100755\n--- a/contrib/diff-highlight/diff-highlight\n+++ b/contrib/diff-highlight/diff-highlight\n@@ -14,6 +14,10 @@ my @removed;\n my @added;\n my $in_hunk;\n \n+# Some scripts may not realize that SIGPIPE is being ignored when launching the\n+# pager--for instance scripts written in Python.\n+$SIG{PIPE} = 'DEFAULT';\n+\n while (<>) {\n \tif (!$in_hunk) {\n \t\tprint;\n-- \n2.0.1\n"},{"id":"251381","messageId":"20141104200932.GA15149@peff.net","threadId":"37877","inReplyTo":"1415131272-89441-1-git-send-email-john@szakmeister.net","subject":"Re: [PATCH v2] diff-highlight: exit when a pipe is broken","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-11-04T20:09:32Z","receivedAt":"2014-11-04T20:09:32Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Nov 04, 2014 at 03:01:12PM -0500, John Szakmeister wrote:\n\n> While using diff-highlight with other tools, I have discovered that Python\n> ignores SIGPIPE by default.  Unfortunately, this also means that tools\n> attempting to launch a pager under Python--and don't realize this is\n> happening--means that the subprocess inherits this setting.  In this case, it\n> means diff-highlight will be launched with SIGPIPE being ignored.  Let's work\n> with those broken scripts by restoring the default SIGPIPE handler.\n> \n> Signed-off-by: John Szakmeister <john@szakmeister.net>\n> ---\n> Incorporates feedback from Jeff King and now we just restore the default signal\n> handler using the correct case of 'DEFAULT'.\n\nThanks, this version looks much simpler. :)\n\nAcked-by: Jeff King <peff@peff.net>\n\n-Peff\n"},{"id":"251384","messageId":"xmqqtx2epu1i.fsf@gitster.dls.corp.google.com","threadId":"37877","inReplyTo":"20141104200932.GA15149@peff.net","subject":"Re: [PATCH v2] diff-highlight: exit when a pipe is broken","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-11-04T20:52:57Z","receivedAt":"2014-11-04T20:52:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Tue, Nov 04, 2014 at 03:01:12PM -0500, John Szakmeister wrote:\n>\n>> While using diff-highlight with other tools, I have discovered that Python\n>> ignores SIGPIPE by default.  Unfortunately, this also means that tools\n>> attempting to launch a pager under Python--and don't realize this is\n>> happening--means that the subprocess inherits this setting.  In this case, it\n>> means diff-highlight will be launched with SIGPIPE being ignored.  Let's work\n>> with those broken scripts by restoring the default SIGPIPE handler.\n>> \n>> Signed-off-by: John Szakmeister <john@szakmeister.net>\n>> ---\n>> Incorporates feedback from Jeff King and now we just restore the default signal\n>> handler using the correct case of 'DEFAULT'.\n>\n> Thanks, this version looks much simpler. :)\n>\n> Acked-by: Jeff King <peff@peff.net>\n\nThanks, both.  The patch looks good.  Will queue.\n"}]}