Skip to content

Commit

Permalink
Handle EINTR when waiting for process
Browse files Browse the repository at this point in the history
  • Loading branch information
patricoferris committed Oct 16, 2022
1 parent b083833 commit 31062c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib_eio_linux/eio_linux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1162,11 +1162,15 @@ let net = object
method getnameinfo = Eio_unix.getnameinfo
end

let rec wait_for_process flags pid =
try Unix.waitpid flags pid with
| Unix.Unix_error (Unix.EINTR, _, _) -> wait_for_process flags pid

let pid_to_process close pid = object
inherit Eio.Process.t
method pid = pid
method status =
match Eio_unix.run_in_systhread @@ fun () -> let v = Unix.waitpid [] pid in close (); v with
match Eio_unix.run_in_systhread @@ fun () -> let v = wait_for_process [] pid in close (); v with
| _, WEXITED i -> Exited i
| _, WSIGNALED i -> Signaled i
| _, WSTOPPED i -> Stopped i
Expand Down Expand Up @@ -1204,7 +1208,7 @@ let process = object
let process = pid_to_process close pid in
let cleanup () =
try
ignore (Unix.waitpid [] pid);
ignore (wait_for_process [] pid);
close ()
with Unix.Unix_error (ECHILD, _, _) -> ()
in
Expand Down

0 comments on commit 31062c6

Please sign in to comment.