From cebc677e01c64c4a3f7081f85e37f3b61a112b68 Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Wed, 9 Mar 2016 16:23:33 +0100 Subject: Win: kill unreliable hence do not waitpid after kill -9 (Close #4369) This commit also completes 74bd95d10b9f4cccb4bd5b855786c444492b201b --- lib/spawn.ml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'lib/spawn.ml') 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 -- cgit v1.2.3