package current

  1. Overview
  2. Docs

Helper functions for spawning sub-processes.

val exec : ?cwd:Fpath.t -> ?stdin:string -> ?pp_error_command:(Stdlib.Format.formatter -> unit) -> cancellable:bool -> job:Job.t -> Lwt_process.command -> unit or_error Lwt.t

exec ~job cmd uses Lwt_process to run cmd, with output to job's log.

  • parameter cwd

    Sets the current working directory for this command.

  • parameter cancellable

    Should the process be terminated if the job is cancelled?

  • parameter stdin

    Data to write to stdin before closing it.

  • parameter pp_error_command

    Format the command for an error message. The default is to print "Command $cmd".

val check_output : ?cwd:Fpath.t -> ?stdin:string -> ?pp_error_command:(Stdlib.Format.formatter -> unit) -> cancellable:bool -> job:Job.t -> Lwt_process.command -> string or_error Lwt.t

Like exec, but return the child's stdout as a string rather than writing it to the log.

val with_tmpdir : ?prefix:string -> (Fpath.t -> 'a Lwt.t) -> 'a Lwt.t

with_tmpdir fn creates a temporary directory, runs fn tmpdir, and then deletes the directory (recursively).

  • parameter prefix

    Allows giving the directory a more meaningful name (for debugging).