Skip to content

Commit

Permalink
Make throw when p is not running.
Browse files Browse the repository at this point in the history
  • Loading branch information
abalkin committed Oct 9, 2017
1 parent 9156fb4 commit 2c5226d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions base/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,8 @@ Get the process ID of a running process. Returns `-1` if the
process is not running.
"""
function Base.getpid(p::Process)
if p.handle != C_NULL
ccall(:jl_uv_process_pid, Cint, (Ptr{Void},), p.handle)
else
Cint(-1)
end
p.handle != C_NULL || error("process not running")
ccall(:jl_uv_process_pid, Cint, (Ptr{Void},), p.handle)
end

struct ProcessChain <: AbstractPipe
Expand Down
2 changes: 1 addition & 1 deletion test/spawn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ let out = Pipe(), proc, pid
close(out.in)
@test parse(Int32, read(out, String)) == pid
@test success(proc)
@test getpid(proc) == -1
@test_throws ErrorException getpid(proc)
end

# issue #6310
Expand Down

0 comments on commit 2c5226d

Please sign in to comment.