diff options
author | Enrico Tassi <Enrico.Tassi@inria.fr> | 2015-12-17 18:33:14 +0100 |
---|---|---|
committer | Enrico Tassi <Enrico.Tassi@inria.fr> | 2015-12-17 18:33:14 +0100 |
commit | a17891fdc314d0fe5246ab785268e2005a8c98b2 (patch) | |
tree | f3ebecb69ae8c42cea9450c81abb70bd3d579a29 /lib/spawn.ml | |
parent | 04394d4f17bff1739930ddca5d31cb9bb031078b (diff) |
spawn: fix leak of file descriptors
The interesting manifestation of the bug was Unix.select
returning no error but the empty list of descriptors, as if
a timeout did happen.
Diffstat (limited to 'lib/spawn.ml')
-rw-r--r-- | lib/spawn.ml | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/spawn.ml b/lib/spawn.ml index 851c6a223..01f6a4f8d 100644 --- a/lib/spawn.ml +++ b/lib/spawn.ml @@ -175,7 +175,7 @@ let is_alive p = p.alive let uid { pid; } = string_of_int pid let unixpid { pid; } = pid -let kill ({ pid = unixpid; oob_req; cin; cout; alive; watch } as p) = +let kill ({ pid = unixpid; oob_resp; oob_req; cin; cout; alive; watch } as p) = p.alive <- false; if not alive then prerr_endline "This process is already dead" else begin try @@ -183,6 +183,8 @@ let kill ({ pid = unixpid; oob_req; cin; cout; alive; watch } as p) = output_death_sentence (uid p) oob_req; close_in_noerr cin; close_out_noerr cout; + close_in_noerr oob_resp; + close_out_noerr oob_req; if Sys.os_type = "Unix" then Unix.kill unixpid 9; p.watch <- None with e -> prerr_endline ("kill: "^Printexc.to_string e) end @@ -247,13 +249,15 @@ let is_alive p = p.alive let uid { pid; } = string_of_int pid let unixpid { pid = pid; } = pid -let kill ({ pid = unixpid; oob_req; cin; cout; alive } as p) = +let kill ({ pid = unixpid; oob_req; oob_resp; cin; cout; alive } as p) = p.alive <- false; if not alive then prerr_endline "This process is already dead" else begin try output_death_sentence (uid p) oob_req; close_in_noerr cin; close_out_noerr cout; + close_in_noerr oob_resp; + close_out_noerr oob_req; if Sys.os_type = "Unix" then Unix.kill unixpid 9; with e -> prerr_endline ("kill: "^Printexc.to_string e) end |