You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@subversion.apache.org by "Vincent Lefevre (Jira)" <ji...@apache.org> on 2021/08/26 17:01:00 UTC

[jira] [Updated] (SVN-4879) Broken pipe on the diff command with --diff-cmd

     [ https://issues.apache.org/jira/browse/SVN-4879?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vincent Lefevre updated SVN-4879:
---------------------------------
    Description: 
When I pipe the output of "svn diff --diff-cmd diff" and a broken pipe occurs on the diff command, I get a "Broken pipe" error:
{noformat}
diff: standard output: Broken pipe
svn: E200012: 'diff' returned 2{noformat}
The cause is that svn runs the diff command with SIGPIPE ignored, so that diff gets an EPIPE write error instead of being killed by the signal. I think that a fix should be to reset SIGPIPE to the default action just before executing the external diff command.

To reproduce the bug:
{noformat}
#!/bin/sh

set -e

export LC_ALL=C

mkdir my-test-svn
cd my-test-svn

svnadmin create svn
svn co file://`pwd`/svn wc
cd wc

seq 10000 > file
svn add file
svn diff | head
svn diff --diff-cmd diff | head

cd ../..
rm -rf my-test-svn{noformat}
 

This gives:
{noformat}
Checked out revision 0.
A file
Index: file
===================================================================
--- file (nonexistent)
+++ file (working copy)
@@ -0,0 +1,10000 @@
+1
+2
+3
+4
+5
Index: file
===================================================================
--- file (nonexistent)
+++ file (working copy)
@@ -0,0 +1,10000 @@
+1
+2
+3
+4
+5
diff: standard output: Broken pipe
svn: E200012: 'diff' returned 2{noformat}
A possible fix (to be tested): instead of ignoring SIGPIPE (using SIG_IGN), use a handler that does nothing. That way, when a command is executed, SIGPIPE will be reset to the default action in the command (i.e. killing the command, unless the command itself changes how it handles SIGPIPE).

  was:
When I pipe the output of "svn diff --diff-cmd diff" and a broken pipe occurs on the diff command, I get a "Broken pipe" error:
{noformat}
diff: standard output: Broken pipe
svn: E200012: 'diff' returned 2{noformat}
The cause is that svn runs the diff command with SIGPIPE ignored, so that diff gets an EPIPE write error instead of being killed by the signal. I think that a fix should be to reset SIGPIPE to the default action just before executing the external diff command.

To reproduce the bug:

 
{noformat}
#!/bin/sh

set -e

export LC_ALL=C

mkdir my-test-svn
cd my-test-svn

svnadmin create svn
svn co file://`pwd`/svn wc
cd wc

seq 10000 > file
svn add file
svn diff | head
svn diff --diff-cmd diff | head

cd ../..
rm -rf my-test-svn{noformat}
 

This gives:
{noformat}
Checked out revision 0.
A file
Index: file
===================================================================
--- file (nonexistent)
+++ file (working copy)
@@ -0,0 +1,10000 @@
+1
+2
+3
+4
+5
Index: file
===================================================================
--- file (nonexistent)
+++ file (working copy)
@@ -0,0 +1,10000 @@
+1
+2
+3
+4
+5
diff: standard output: Broken pipe
svn: E200012: 'diff' returned 2{noformat}
A possible fix (to be tested): instead of ignoring SIGPIPE (using SIG_IGN), use a handler that does nothing. That way, when a command is executed, SIGPIPE will be reset to the default action in the command (i.e. killing the command, unless the command itself changes how it handles SIGPIPE).


> Broken pipe on the diff command with --diff-cmd
> -----------------------------------------------
>
>                 Key: SVN-4879
>                 URL: https://issues.apache.org/jira/browse/SVN-4879
>             Project: Subversion
>          Issue Type: Bug
>          Components: cmdline client
>    Affects Versions: 1.14.1
>         Environment: Debian GNU/Linux.
>            Reporter: Vincent Lefevre
>            Priority: Major
>
> When I pipe the output of "svn diff --diff-cmd diff" and a broken pipe occurs on the diff command, I get a "Broken pipe" error:
> {noformat}
> diff: standard output: Broken pipe
> svn: E200012: 'diff' returned 2{noformat}
> The cause is that svn runs the diff command with SIGPIPE ignored, so that diff gets an EPIPE write error instead of being killed by the signal. I think that a fix should be to reset SIGPIPE to the default action just before executing the external diff command.
> To reproduce the bug:
> {noformat}
> #!/bin/sh
> set -e
> export LC_ALL=C
> mkdir my-test-svn
> cd my-test-svn
> svnadmin create svn
> svn co file://`pwd`/svn wc
> cd wc
> seq 10000 > file
> svn add file
> svn diff | head
> svn diff --diff-cmd diff | head
> cd ../..
> rm -rf my-test-svn{noformat}
>  
> This gives:
> {noformat}
> Checked out revision 0.
> A file
> Index: file
> ===================================================================
> --- file (nonexistent)
> +++ file (working copy)
> @@ -0,0 +1,10000 @@
> +1
> +2
> +3
> +4
> +5
> Index: file
> ===================================================================
> --- file (nonexistent)
> +++ file (working copy)
> @@ -0,0 +1,10000 @@
> +1
> +2
> +3
> +4
> +5
> diff: standard output: Broken pipe
> svn: E200012: 'diff' returned 2{noformat}
> A possible fix (to be tested): instead of ignoring SIGPIPE (using SIG_IGN), use a handler that does nothing. That way, when a command is executed, SIGPIPE will be reset to the default action in the command (i.e. killing the command, unless the command itself changes how it handles SIGPIPE).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)