Skip to content

Commit

Permalink
Process.exitcode needs to be an Int64 to cover the range typemin(Int3…
Browse files Browse the repository at this point in the history
…2):typemax(UInt32) that may be returned by spawn on windows (fixes #12176)
  • Loading branch information
vtjnash committed Aug 22, 2015
1 parent 1481981 commit c565cd0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions base/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ type Process <: AbstractPipe
in::AsyncStream
out::AsyncStream
err::AsyncStream
exitcode::Int32
exitcode::Int64
termsignal::Int32
exitcb::Callback
exitnotify::Condition
Expand All @@ -222,7 +222,10 @@ type Process <: AbstractPipe
if !isa(err, AsyncStream) || err === DevNull
err=DevNull
end
this = new(cmd, handle, in, out, err, typemin(Int32), typemin(Int32), false, Condition(), false, Condition())
this = new(cmd, handle, in, out, err,
typemin(fieldtype(Process, :exitcode)),
typemin(fieldtype(Process, :termsignal)),
false, Condition(), false, Condition())
finalizer(this, uvfinalize)
this
end
Expand Down Expand Up @@ -265,7 +268,7 @@ function uv_return_spawn(p::Ptr{Void}, exit_status::Int64, termsignal::Int32)
data = ccall(:jl_uv_process_data, Ptr{Void}, (Ptr{Void},), p)
data == C_NULL && return
proc = unsafe_pointer_to_objref(data)::Process
proc.exitcode = Int32(exit_status)
proc.exitcode = exit_status
proc.termsignal = termsignal
if isa(proc.exitcb, Function) proc.exitcb(proc, exit_status, termsignal) end
ccall(:jl_close_uv, Void, (Ptr{Void},), proc.handle)
Expand Down Expand Up @@ -587,7 +590,7 @@ function _contains_newline(bufptr::Ptr{Void}, len::Int32)
end

## process status ##
process_running(s::Process) = s.exitcode == typemin(Int32)
process_running(s::Process) = s.exitcode == typemin(fieldtype(Process, :exitcode))
process_running(s::Vector{Process}) = any(process_running, s)
process_running(s::ProcessChain) = process_running(s.processes)

Expand Down
2 changes: 1 addition & 1 deletion base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ end
## Libuv error handling ##
type UVError <: Exception
prefix::AbstractString
code::Int64 # TODO: change to Int32 when updating to libuv 1.0
code::Int32
UVError(p::AbstractString,code::Integer)=new(p,code)
end

Expand Down

0 comments on commit c565cd0

Please sign in to comment.