Module OpamProcess
Process and job handling, with logs, termination status, etc.
val command : ?env:string array -> ?verbose:bool -> ?name:string -> ?metadata:(string * string) list -> ?dir:string -> ?allow_stdin:bool -> ?stdout:string -> ?text:string -> string -> string list -> commandBuilds a shell command for later execution.
- parameter env
environment for the command
- parameter verbose
force verbosity
- parameter name
title, used to name log files, etc.
- parameter metadata
additional info to log
- parameter dir
CWD for the command
- parameter allow_stdin
whether to forward stdin
- parameter stdout
redirect stdout to the given file instead of the logs
- parameter text
Short text that may be displayed in the status-line
- parameter command
The command itself
- parameter args
Command-line arguments
val string_of_command : command -> stringval text_of_command : command -> string optionval is_verbose_command : command -> boolval make_command_text : ?color:OpamConsole.text_style -> string -> ?args:string list -> string -> stringReturns a label suitable for printing the summary of running commands. First string is the topic (e.g. package), second the action (e.g. command name). Optional command arguments may be used for details (e.g. make action).
type t={}The type for processes
type result={}Process results
val run : command -> resultrun commandsynchronously call the commandcommand.cmdwith argumentscommand.args. It waits until the process is finished. The filesname.info,name.env,name.outandname.err, withname = command.cmd_nameare created, and contain the process main description, the environment variables, the standard output and the standard error. Don't forget to callcleanup resultafterwards
val run_background : command -> tSame as
run, but doesn't wait. Use wait_one to wait and collect results; Don't forget to callcleanup resultafterwards
val dry_run_background : command -> tSimilar to
run_background, except that no process is created, and a dummy process (suitable for dry_wait_one) is returned.
val wait : t -> resultwait pwaits for the processuspto end and returns its results. Be careful to handle Sys.Break
val dontwait : t -> result optionLike
wait, but returns None immediately if the process hasn't ended
val wait_one : t list -> t * resultWait for the first of the listed processes to terminate, and return its termination status
val dry_wait_one : t list -> t * resultSimilar to
wait_onefor simulations, to be used withdry_run_background
val interrupt : t -> unitSend SIGINT to a process (or SIGKILL on Windows)
val is_success : result -> boolIs the process result a success?
val is_failure : result -> boolIs the process result a failure?
val cleanup : ?force:bool -> result -> unitShould be called after process termination, to cleanup temporary files. Leaves artefacts in case OpamGlobals.debug is on and on failure, unless force has been set.
val check_success_and_cleanup : result -> boolLike
is_success, with an added cleanup side-effect (ascleanup ~force:true). Use this when not returning 0 is not an error case: since the default behaviour is to cleanup only when the command returned 0, which is not what is expected in that case.
Misc
val string_of_result : ?color:OpamConsole.text_style -> result -> stringDetailed report on process outcome
val result_summary : result -> stringShort report on process outcome
module Job : sig ... endHigher-level interface to allow parallelism
type 'a job= 'a Job.Op.job