@@ -1244,6 +1244,14 @@ function _redirect_io_libc(stream, unix_fd::Int)
12441244 dup (posix_fd, RawFD (unix_fd))
12451245 nothing
12461246end
1247+ function _set_cglobal_stdio (f:: RedirectStdStream , handle:: Union{LibuvStream, IOStream} )
1248+ c_sym = f. unix_fd == 0 ? cglobal (:jl_uv_stdin , Ptr{Cvoid}) :
1249+ f. unix_fd == 1 ? cglobal (:jl_uv_stdout , Ptr{Cvoid}) :
1250+ f. unix_fd == 2 ? cglobal (:jl_uv_stderr , Ptr{Cvoid}) :
1251+ C_NULL
1252+ c_sym == C_NULL || unsafe_store! (c_sym, handle. handle)
1253+ nothing
1254+ end
12471255function _redirect_io_global (io, unix_fd:: Int )
12481256 unix_fd == 0 && (global stdin = io)
12491257 unix_fd == 1 && (global stdout = io)
@@ -1252,18 +1260,15 @@ function _redirect_io_global(io, unix_fd::Int)
12521260end
12531261function (f:: RedirectStdStream )(handle:: Union{LibuvStream, IOStream} )
12541262 _redirect_io_libc (handle, f. unix_fd)
1255- c_sym = f. unix_fd == 0 ? cglobal (:jl_uv_stdin , Ptr{Cvoid}) :
1256- f. unix_fd == 1 ? cglobal (:jl_uv_stdout , Ptr{Cvoid}) :
1257- f. unix_fd == 2 ? cglobal (:jl_uv_stderr , Ptr{Cvoid}) :
1258- C_NULL
1259- c_sym == C_NULL || unsafe_store! (c_sym, handle. handle)
1263+ _set_cglobal_stdio (f, handle)
12601264 _redirect_io_global (handle, f. unix_fd)
12611265 return handle
12621266end
12631267function (f:: RedirectStdStream )(:: DevNull )
12641268 nulldev = @static Sys. iswindows () ? " NUL" : " /dev/null"
12651269 handle = open (nulldev, write= f. writable)
12661270 _redirect_io_libc (handle, f. unix_fd)
1271+ _set_cglobal_stdio (f, handle)
12671272 close (handle) # handle has been dup'ed in _redirect_io_libc
12681273 _redirect_io_global (devnull , f. unix_fd)
12691274 return devnull
0 commit comments