Skip to content

Commit

Permalink
Update eio_linux
Browse files Browse the repository at this point in the history
  • Loading branch information
patricoferris committed Aug 21, 2023
1 parent 714c7bb commit 316e43d
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions lib_eio_linux/eio_linux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,23 @@ type stdenv = Eio_unix.Stdenv.base

module Process = Low_level.Process

let process proc : Eio.Process.t = object
method pid = Process.pid proc
let process proc : Eio_unix.Process.process_ty Eio.Resource.t =
let module T = struct
type t = unit
type tag = [ `Generic | `Unix ]

method await =
match Eio.Promise.await @@ Process.exit_status proc with
| Unix.WEXITED i -> `Exited i
| Unix.WSIGNALED i -> `Signaled i
| Unix.WSTOPPED _ -> assert false
let pid () = Process.pid proc

method signal i = Process.signal proc i
end
let await () =
match Eio.Promise.await @@ Process.exit_status proc with
| Unix.WEXITED i -> `Exited i
| Unix.WSIGNALED i -> `Signaled i
| Unix.WSTOPPED _ -> assert false

let signal () i = Process.signal proc i
end in
Eio.Resource.T
((), (Eio.Process.Pi.process (module T)))

(* fchdir wants just a directory FD, not an FD and a path like the *at functions. *)
let with_dir dir_fd path fn =
Expand All @@ -343,8 +349,9 @@ let with_dir dir_fd path fn =

module Process_impl = struct
module T = struct
type t = unit

let spawn_unix ~sw ?cwd ~env ~fds ~executable args =
let spawn_unix () ~sw ?cwd ~env ~fds ~executable args =
let actions = Process.Fork_action.[
Eio_unix.Private.Fork_action.inherit_fds fds;
execve executable ~argv:(Array.of_list args) ~env
Expand All @@ -365,9 +372,9 @@ module Process_impl = struct
include Eio_unix.Process.Make_proc (T)
end

let process_mgr : Eio_unix.Process.mgr_ty r =
let handler = Eio_unix.Process.Pi.mgr (module Process_impl) in
Eio.Resource.T ((), handler)
let process_mgr : Eio_unix.Process.ty r =
let h = Eio_unix.Process.Pi.mgr_unix (module Process_impl) in
Eio.Resource.T ((), h)

let wrap_backtrace fn x =
match fn x with
Expand Down

0 comments on commit 316e43d

Please sign in to comment.