Skip to content

Commit

Permalink
FileWatching: Dump open file descriptors on failure
Browse files Browse the repository at this point in the history
If the FDs we allocated are too high, we leaked fds somewhere.
On linux it's fairly easy to dump out information about all
active FDs, so do that in the failure case, so the logs can
help in debugging.
  • Loading branch information
Keno committed Dec 19, 2020
1 parent 89fa9c6 commit 6ae3ded
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions stdlib/FileWatching/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ for i in 1:n
end
Ctype = Sys.iswindows() ? Ptr{Cvoid} : Cint
FDmax = Sys.iswindows() ? 0x7fff : (n + 60) # expectations on reasonable values
@test 0 <= Int(Base.cconvert(Ctype, pipe_fds[i][1])) <= FDmax
@test 0 <= Int(Base.cconvert(Ctype, pipe_fds[i][2])) <= FDmax
fd_in_limits =
0 <= Int(Base.cconvert(Ctype, pipe_fds[i][1])) <= FDmax &&
0 <= Int(Base.cconvert(Ctype, pipe_fds[i][2])) <= FDmax
# Dump out what file descriptors are open for easier debugging of failure modes
if !fd_in_limits && Sys.islinux()
run(`ls -la /proc/$(getpid())/fd`)
end
@test fd_in_limits
end

function pfd_tst_reads(idx, intvl)
Expand Down

0 comments on commit 6ae3ded

Please sign in to comment.