Skip to content

Commit b6590d4

Browse files
KenoKristofferC
authored andcommitted
FileWatching: Dump open file descriptors on failure
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. (cherry picked from commit 6ae3ded)
1 parent eb1efe5 commit b6590d4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

stdlib/FileWatching/test/runtests.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ for i in 1:n
2323
end
2424
Ctype = Sys.iswindows() ? Ptr{Cvoid} : Cint
2525
FDmax = Sys.iswindows() ? 0x7fff : (n + 60) # expectations on reasonable values
26-
@test 0 <= Int(Base.cconvert(Ctype, pipe_fds[i][1])) <= FDmax
27-
@test 0 <= Int(Base.cconvert(Ctype, pipe_fds[i][2])) <= FDmax
26+
fd_in_limits =
27+
0 <= Int(Base.cconvert(Ctype, pipe_fds[i][1])) <= FDmax &&
28+
0 <= Int(Base.cconvert(Ctype, pipe_fds[i][2])) <= FDmax
29+
# Dump out what file descriptors are open for easier debugging of failure modes
30+
if !fd_in_limits && Sys.islinux()
31+
run(`ls -la /proc/$(getpid())/fd`)
32+
end
33+
@test fd_in_limits
2834
end
2935

3036
function pfd_tst_reads(idx, intvl)

0 commit comments

Comments
 (0)