aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/spawn.ml
diff options
context:
space:
mode:
authorGravatar Enrico Tassi <Enrico.Tassi@inria.fr>2016-03-09 16:23:33 +0100
committerGravatar Enrico Tassi <Enrico.Tassi@inria.fr>2016-03-09 16:29:01 +0100
commitcebc677e01c64c4a3f7081f85e37f3b61a112b68 (patch)
treeaa286631cfb2b89d0d42f7c5b1321033cf497602 /lib/spawn.ml
parenta5ae3b2856e6cc6683652a0abb5a84b9787527c0 (diff)
Win: kill unreliable hence do not waitpid after kill -9 (Close #4369)
This commit also completes 74bd95d10b9f4cccb4bd5b855786c444492b201b
Diffstat (limited to 'lib/spawn.ml')
-rw-r--r--lib/spawn.ml22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/spawn.ml b/lib/spawn.ml
index 4d35ded90..fda4b4239 100644
--- a/lib/spawn.ml
+++ b/lib/spawn.ml
@@ -220,10 +220,13 @@ let stats { oob_req; oob_resp; alive } =
input_value oob_resp
let rec wait p =
- try snd (Unix.waitpid [] p.pid)
- with
- | Unix.Unix_error (Unix.EINTR, _, _) -> wait p
- | Unix.Unix_error _ -> Unix.WEXITED 0o400
+ (* On windows kill is not reliable, so wait may never return. *)
+ if Sys.os_type = "Unix" then
+ try snd (Unix.waitpid [] p.pid)
+ with
+ | Unix.Unix_error (Unix.EINTR, _, _) -> wait p
+ | Unix.Unix_error _ -> Unix.WEXITED 0o400
+ else Unix.WEXITED 0o400
end
@@ -267,8 +270,13 @@ let stats { oob_req; oob_resp; alive } =
flush oob_req;
let RespStats g = input_value oob_resp in g
-let wait { pid = unixpid } =
- try snd (Unix.waitpid [] unixpid)
- with Unix.Unix_error _ -> Unix.WEXITED 0o400
+let rec wait p =
+ (* On windows kill is not reliable, so wait may never return. *)
+ if Sys.os_type = "Unix" then
+ try snd (Unix.waitpid [] p.pid)
+ with
+ | Unix.Unix_error (Unix.EINTR, _, _) -> wait p
+ | Unix.Unix_error _ -> Unix.WEXITED 0o400
+ else Unix.WEXITED 0o400
end