Skip to content

Commit

Permalink
process: make SIGPIPE an always failure (JuliaLang#39574)
Browse files Browse the repository at this point in the history
This error code does not exist on Windows, so any code that relied on
this was broken (would fail this test) on that platform already. In most
cases, it was actually a serious error too, such as `cp -v` or `tar -v`,
which will indeed fail midway and give corrupt results if you do not read
their output to completion!

Reverts JuliaLang#1469, in essence
  • Loading branch information
vtjnash authored and johanmon committed Jul 5, 2021
1 parent 280e591 commit 560709a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ function test_success(proc::Process)
#TODO: this codepath is not currently tested
throw(_UVError("could not start process " * repr(proc.cmd), proc.exitcode))
end
return proc.exitcode == 0 && (proc.termsignal == 0 || proc.termsignal == SIGPIPE)
return proc.exitcode == 0 && proc.termsignal == 0
end

function success(x::Process)
Expand Down
4 changes: 2 additions & 2 deletions test/spawn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ out = read(`$echocmd hello` & `$echocmd world`, String)

@test (run(`$printfcmd " \033[34m[stdio passthrough ok]\033[0m\n"`); true)

# Test for SIGPIPE being treated as normal termination (throws an error if broken)
Sys.isunix() && run(pipeline(yescmd, `head`, devnull))
# Test for SIGPIPE being a failure condition
@test_throws ProcessFailedException run(pipeline(yescmd, `head`, devnull))

let p = run(pipeline(yescmd, devnull), wait=false)
t = @async kill(p)
Expand Down

0 comments on commit 560709a

Please sign in to comment.