Module Core.Exit

types for exit status with lots of extra info for fun and profit.

type status = Unix.process_status =
  1. | WEXITED of int
  2. | WSIGNALED of int
  3. | WSTOPPED of int

including the Unix status type here so you don't have to import it extra.

type t =
  1. | Exit : {
    1. pid : int;
    2. cmd : ('a, 'b, 'c) Cmd.t;
    3. status : status;
    } -> t

This is a type you have my full permission to dig around in. I included the pid in the exit status and I will tell you why: I don't know.

Still, could be useful if you're registering PIDs in a map or something and you want to act on items in the map based on the exit status. I don't know. Anyway, it's there if you want it.

val pp : Stdlib.Format.formatter -> t -> unit

Obligatory pretty printer, for your debugging pleasure.

val show : t -> string
val res : (t * 'a) -> ('a, t) Stdlib.result

A function to turn a non-zero exit status into an Error Exit.t and zero into an Ok 'a value. Exit.t * 'a happens to be the return type of Exec.in_context, so this is a helper function to convert that type to a result.

val exn : (t * 'a) -> 'a

Same as above, only it raises Subprocess_error on non-zero.

val string_error : ('a, t) Stdlib.result -> ('a, string) Stdlib.result

Helper function to convert your Exit.t monads into string monads so they compose a little better.

val status_int : t -> int

Convert the exit status into an integer.