@@ -187,8 +187,12 @@ function TTY(fd::RawFD; readable::Bool = false)
187187 return tty
188188end
189189
190- show (io:: IO ,stream:: LibuvServer ) = print (io, typeof (stream), " (" , uv_status_string (stream), " )" )
191- show (io:: IO , stream:: LibuvStream ) = print (io, typeof (stream), " (" , uv_status_string (stream), " , " ,
190+ show (io:: IO , stream:: LibuvServer ) = print (io, typeof (stream), " (" ,
191+ _fd (stream), " " ,
192+ uv_status_string (stream), " )" )
193+ show (io:: IO , stream:: LibuvStream ) = print (io, typeof (stream), " (" ,
194+ _fd (stream), " " ,
195+ uv_status_string (stream), " , " ,
192196 nb_available (stream. buffer)," bytes waiting)" )
193197
194198# Shared LibuvStream object interface
521525
522526show (io:: IO , stream:: Pipe ) = print (io,
523527 " Pipe(" ,
528+ _fd (stream. in), " " ,
524529 uv_status_string (stream. in), " => " ,
530+ _fd (stream. out), " " ,
525531 uv_status_string (stream. out), " , " ,
526532 nb_available (stream), " bytes waiting)" )
527533
@@ -925,12 +931,16 @@ Connect to the named pipe / UNIX domain socket at `path`.
925931"""
926932connect (path:: AbstractString ) = connect (init_pipe! (PipeEndpoint (); readable= false , writable= false , julia_only= true ),path)
927933
934+ const OS_HANDLE = is_windows () ? WindowsRawSocket : RawFD
935+ const INVALID_OS_HANDLE = is_windows () ? WindowsRawSocket (Ptr {Void} (- 1 )) : RawFD (- 1 )
928936_fd (x:: IOStream ) = RawFD (fd (x))
929- if is_windows ()
930- _fd (x:: LibuvStream ) = WindowsRawSocket (
931- ccall (:jl_uv_handle , Ptr{Void}, (Ptr{Void},), x. handle))
932- else
933- _fd (x:: LibuvStream ) = RawFD (ccall (:jl_uv_handle , Int32, (Ptr{Void},), x. handle))
937+ function _fd (x:: Union{LibuvStream, LibuvServer} )
938+ fd = Ref {OS_HANDLE} (INVALID_OS_HANDLE)
939+ if x. status != StatusUninit && x. status != StatusClosed
940+ err = ccall (:uv_fileno , Int32, (Ptr{Void}, Ptr{OS_HANDLE}), x. handle, fd)
941+ # handle errors by returning INVALID_OS_HANDLE
942+ end
943+ return fd[]
934944end
935945
936946for (x, writable, unix_fd, c_symbol) in
0 commit comments