File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7878module Env : Env = (val if Sys. win32 then (module Env_win32 ) else (module Env_unix ) : Env )
7979
8080module Pgid = struct
81- type t = int
81+ type t =
82+ | New
83+ | Pid of Pid .t
8284
83- let new_process_group = 0
85+ let new_process_group = New
86+ let of_pid p = Pid p
8487
85- let of_pid = function
86- | 0 -> raise ( Invalid_argument " bad pid: 0 (hint: use [Pgid.new_process_group]) " )
87- | t -> if t < 0 then raise ( Invalid_argument ( " bad pid: " ^ string_of_int t)) else t
88+ let to_int = function
89+ | New -> 0
90+ | Pid p -> Pid. to_int p
8891 ;;
8992end
9093
@@ -114,6 +117,7 @@ let spawn_unix
114117 ~setpgid
115118 ~sigprocmask
116119 =
120+ let setpgid = Option. map ~f: Pgid. to_int setpgid in
117121 spawn_unix ~env ~cwd ~prog ~argv ~stdin ~stdout ~stderr ~use_vfork ~setpgid ~sigprocmask
118122 |> Pid. of_int_exn
119123;;
Original file line number Diff line number Diff line change @@ -42,8 +42,7 @@ module Pgid : sig
4242 [setpgid(0, 0)]. *)
4343 val new_process_group : t
4444
45- (* * Raises [Invalid_arg] if the value is not strictly positive. *)
46- val of_pid : int -> t
45+ val of_pid : Pid .t -> t
4746end
4847
4948(* * Spawn a sub-command and return its PID. This function is low-level and
You can’t perform that action at this time.
0 commit comments