Skip to content

Commit

Permalink
Add show method for RawFD
Browse files Browse the repository at this point in the history
This prevents invalidation via `convert(::Type{Ptr{Cint}}, fd)`.
  • Loading branch information
timholy committed May 18, 2020
1 parent 93ed743 commit a7b178f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/libc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ dup(src::RawFD, target::RawFD) = systemerror("dup", -1 ==
ccall((@static Sys.iswindows() ? :_dup2 : :dup2), Int32,
(RawFD, RawFD), src, target))

show(io::IO, fd::RawFD) = print(io, "RawFD(", bitcast(UInt32, fd), ')') # avoids invalidation via show_default

# Wrapper for an OS file descriptor (for Windows)
if Sys.iswindows()
primitive type WindowsRawSocket sizeof(Ptr) * 8 end # On Windows file descriptors are HANDLE's and 64-bit on 64-bit Windows
Expand Down

0 comments on commit a7b178f

Please sign in to comment.