File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -79,13 +79,17 @@ let fd_list () =
79
79
let path = " /proc/self/fd" in
80
80
(* get rid of the fd used to read the directory *)
81
81
Array. fold_right
82
- (fun fd_num l ->
83
- try (fd_num, Unix. readlink (Filename. concat path fd_num)) :: l
84
- with _ -> l
82
+ (fun fd_num (l , n ) ->
83
+ try
84
+ let pair = (fd_num, Unix. readlink (Filename. concat path fd_num)) in
85
+ (pair :: l, n + 1 )
86
+ with _ -> (l, n)
85
87
)
86
- (Sys. readdir path) []
88
+ (Sys. readdir path) ( [] , 0 )
87
89
88
- let fd_count () = List. length (fd_list () )
90
+ let fd_count () =
91
+ let _, n = fd_list () in
92
+ n
89
93
90
94
let irrelevant_strings = [" irrelevant" ; " not" ; " important" ]
91
95
@@ -259,7 +263,7 @@ let slave = function
259
263
List. filter (fun x -> not (List. mem x irrelevant_strings)) rest
260
264
in
261
265
(* Check that these fds are present *)
262
- let pairs = fd_list () in
266
+ let pairs, _ = fd_list () in
263
267
(* Filter any of stdin,stdout,stderr which have been mapped to /dev/null *)
264
268
let filtered =
265
269
List. filter
You can’t perform that action at this time.
0 commit comments