From c565cd04c056babbb51239e8f8e5b4fc716ea28f Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 21 Aug 2015 16:59:36 -0400 Subject: [PATCH] Process.exitcode needs to be an Int64 to cover the range typemin(Int32):typemax(UInt32) that may be returned by spawn on windows (fixes #12176) --- base/process.jl | 11 +++++++---- base/stream.jl | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/base/process.jl b/base/process.jl index 981d0c48fe105..56f41390d7655 100644 --- a/base/process.jl +++ b/base/process.jl @@ -206,7 +206,7 @@ type Process <: AbstractPipe in::AsyncStream out::AsyncStream err::AsyncStream - exitcode::Int32 + exitcode::Int64 termsignal::Int32 exitcb::Callback exitnotify::Condition @@ -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 @@ -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) @@ -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) diff --git a/base/stream.jl b/base/stream.jl index b874ee4b4e287..18b2085369560 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -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