Commits

camlspotter committed a2b0848

move back Process_status.t to Unix.process_status

  • Participants
  • Parent commits 80f17da

Comments (0)

Files changed (2)

File lib/xunix.ml

     
 module Process_status = struct
 
-  type t =
-    [ `Exited   of int
-    | `Signaled of int
-    | `Stopped  of int
-    ]
-
-  let of_process_status = function
-    | WEXITED   n -> `Exited   n
-    | WSIGNALED n -> `Signaled n
-    | WSTOPPED  n -> `Stopped  n
+  type t = Unix.process_status
 
   let failwith ?name = 
     let name = match name with None -> "" | Some n -> n ^ ": " in
     function
-      | `Exited n   -> Exn.failwithf "%sprocess exited with id %d" name n
-      | `Signaled n -> Exn.failwithf "%sprocess killed by signal %d" name n
-      | `Stopped n  -> Exn.failwithf "%sprocess stopped by signal %d" name n
+      | WEXITED n   -> Exn.failwithf "%sprocess exited with id %d" name n
+      | WSIGNALED n -> Exn.failwithf "%sprocess killed by signal %d" name n
+      | WSTOPPED n  -> Exn.failwithf "%sprocess stopped by signal %d" name n
 
 end
 
 
 let rec waitpid_non_intr pid =
   try 
-    Tuple.map_snd Process_status.of_process_status & waitpid [] pid 
+    waitpid [] pid 
   with Unix_error (EINTR, _, _) -> waitpid_non_intr pid
 ;;
     
 
 let cmp p1 p2 = 
   match command ["cmp"; p1; p2] ignore with
-  | `Exited 0 -> `Same
-  | `Exited 1 -> `Different
-  | `Exited 2 -> `Error
+  | WEXITED 0 -> `Same
+  | WEXITED 1 -> `Different
+  | WEXITED 2 -> `Error
   | _ -> `Error (* something extremely wrong happened *)
 
 let gen_timed get minus f v = 

File lib/xunix.mli

 
 module Process_status : sig
 
-  type t =
-    [ `Exited   of int
-    | `Signaled of int
-    | `Stopped  of int
-    ]
+  type t = Unix.process_status
 
-  val failwith : ?name:string -> [< t ] -> 'a
+  val failwith : ?name:string -> t -> 'a
 
 end
 
 val shell_command :
   string 
   -> ([> `Out | `Err] * [ `Read of string | `EOF ] -> unit) 
-  -> [> Process_status.t ]
+  -> Unix.process_status
 (** Execute a shell command using /bin/sh *)
 
 val command :
   string list
   -> ([> `Out | `Err] * [ `Read of string | `EOF ] -> unit) 
-  -> [> Process_status.t ]
+  -> Unix.process_status
 (** Same as [shell_command] but it takes the command and arguments as a list of string,
     then directly executed by [Unix.execvp]. *)
 
   string 
   -> ('st -> [> `Out | `Err] * [ `Read of string | `EOF ] -> 'st) 
   -> init: 'st 
-  -> [> Process_status.t ] * 'st
+  -> Unix.process_status * 'st
 (** Execute a shell command using /bin/sh *)
 
 val command' :
   string list
   -> ('st -> [> `Out | `Err] * [ `Read of string | `EOF ] -> 'st) 
   -> init: 'st
-  -> [> Process_status.t ] * 'st
+  -> Unix.process_status * 'st
 (** Same as [shell_command] but it takes the command and arguments as a list of string,
     then directly executed by [Unix.execvp]. *)
 
 val shell_command_stdout :
-  string -> [> Process_status.t ] * string list
+  string -> Unix.process_status * string list
 (** Execute a shell command using /bin/sh
     Err is printed to stderr.
  *)