Skip to content

Commit e5e570b

Browse files
authored
[Distributed] Set stdin to devnull before closing it (JuliaLang/julia#44881)
* [Distributed] Set stdin to devnull before closing it Distributed closes and destroys stdin, but some tests attempted to explicitly use it, leading to test problems. We previously interpreted this as passing devnull, but this is better to be explicit. * Revert "Testsystem: for now, move the REPL tests to node 1 (JuliaLang/julia#44880)" This reverts commit 7401e92a930ab51ff74e67a27152df5c2acd459b.
1 parent 87b879f commit e5e570b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/cluster.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ start_worker(cookie::AbstractString=readline(stdin); kwargs...) = start_worker(s
232232
function start_worker(out::IO, cookie::AbstractString=readline(stdin); close_stdin::Bool=true, stderr_to_stdout::Bool=true)
233233
init_multi()
234234

235-
close_stdin && close(stdin) # workers will not use it
235+
if close_stdin # workers will not use it
236+
redirect_stdin(devnull)
237+
close(stdin)
238+
end
236239
stderr_to_stdout && redirect_stderr(stdout)
237240

238241
init_worker(cookie)

test/distributed_exec.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,11 @@ cluster_cookie("")
16161616
for close_stdin in (true, false), stderr_to_stdout in (true, false)
16171617
local npids = addprocs_with_testenv(RetainStdioTester(close_stdin,stderr_to_stdout))
16181618
@test remotecall_fetch(myid, npids[1]) == npids[1]
1619-
@test close_stdin != remotecall_fetch(()->isopen(stdin), npids[1])
1619+
if close_stdin
1620+
@test remotecall_fetch(()->stdin === devnull && !isreadable(stdin), npids[1])
1621+
else
1622+
@test remotecall_fetch(()->stdin !== devnull && isopen(stdin) && isreadable(stdin), npids[1])
1623+
end
16201624
@test stderr_to_stdout == remotecall_fetch(()->(stderr === stdout), npids[1])
16211625
rmprocs(npids)
16221626
end

0 commit comments

Comments
 (0)