@@ -188,8 +188,13 @@ let kill_process (p: proc) =
188188 attempt (fun () -> Unix. close (Unix. descr_of_in_channel p.inc));
189189 attempt (fun () -> Unix. close (Unix. descr_of_in_channel p.errc));
190190 attempt (fun () -> Unix. close (Unix. descr_of_out_channel p.outc));
191+ (* Try to kill, but the process may already be gone. On Unix we
192+ get ESRCH. On Windows, we apparently get EACCES (permission denied). *)
191193 (try Unix. kill p.pid Sys. sigkill
192- with Unix. Unix_error (Unix. ESRCH, _ , _ ) -> () );
194+ with Unix. Unix_error (Unix. ESRCH, _ , _ ) -> ()
195+ | Unix. Unix_error (Unix. EACCES, _ , _ ) when FStarC_Platform. system = FStarC_Platform. Windows -> ()
196+ );
197+
193198 (* Avoid zombie processes (Unix.close_process does the same thing. *)
194199 waitpid_ignore_signals p.pid;
195200 (* print_string ("Killed process " ^ p.id ^ "\n" ^ (stack_dump())); *)
@@ -341,29 +346,39 @@ let ask_process
341346 kill_process p; raise e
342347
343348let get_file_extension (fn :string ) : string = snd (BatString. rsplit fn " ." )
349+
350+ (* NOTE: Working around https://github.com/ocaml-batteries-team/batteries-included/issues/1136 *)
351+ let is_absolute_windows (path_str : string ) : bool =
352+ if FStarC_Platform. system = FStarC_Platform. Windows then
353+ match BatString. to_list path_str with
354+ | '\\' :: _ -> true
355+ | letter :: ':' :: '\\' :: _ -> BatChar. is_letter letter
356+ | _ -> false
357+ else
358+ false
359+
344360let is_path_absolute path_str =
345361 let open Batteries.Incubator in
346362 let open BatPathGen.OfString in
347- let path_str' = of_string path_str in
348- is_absolute path_str'
363+ let path = of_string path_str in
364+ is_absolute path || is_absolute_windows path_str
365+
349366let join_paths path_str0 path_str1 =
350367 let open Batteries.Incubator in
351368 let open BatPathGen.OfString in
352369 let open BatPathGen.OfString.Operators in
353370 to_string ((of_string path_str0) //@ (of_string path_str1))
354371
355372let normalize_file_path (path_str :string ) =
356- let open Batteries.Incubator in
357- let open BatPathGen.OfString in
358- let open BatPathGen.OfString.Operators in
359- to_string
360- (normalize_in_tree
361- (let path = of_string path_str in
362- if is_absolute path then
363- path
364- else
365- let pwd = of_string (BatSys. getcwd () ) in
366- pwd //@ path))
373+ if is_path_absolute path_str then
374+ path_str
375+ else
376+ let open Batteries.Incubator in
377+ let open BatPathGen.OfString in
378+ let open BatPathGen.OfString.Operators in
379+ let path = of_string path_str in
380+ let cwd = of_string (BatSys. getcwd () ) in
381+ to_string (normalize_in_tree (cwd //@ path))
367382
368383type stream_reader = BatIO .input
369384let open_stdin () = BatIO. stdin
0 commit comments