Skip to content
This repository
tag: v737
Fetching contributors…

Cannot retrieve contributors at this time

file 60 lines (44 sloc) 2.348 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)

(** Module to manage a single process

@author Mathieu Baudet
@author Hugo Venturini
*)

(** Type of a process *)
type t


type chans = {
  p_stdin : Unix.file_descr;
  p_stdout : Unix.file_descr;
  p_stderr : Unix.file_descr;
}


(** Launches the given executable with the given options. The child process is launched after a double fork mechanism which implies that there will be no zombie process if the child dies before the father and the latter does not wait for it to finish.
@return the running process and channels to communicate with it
*)
val start : exec_name:string -> options:string list -> t * chans

(** Creates a [t] from a given pid *)
val recover_from_pid : exec_name:string -> options:string list -> int -> t

(** [send_signal ?maxattempt:x ?interval:t ~signal:s sched p cont] schedules in [sched] the sending to process [p] of the signal [s] (see the [Sys] module) every [t] seconds until success but not more than [x] times. It then calls continuation [cont] with the result ([true] on success, [false] otherwise.
@param maxattempt number of attempts to send the signal, default is 3
@param interval time between to attempt to send the signal, default is 2 sec.
*)
val send_signal : ?maxattempts:int -> ?interval:Time.t ->
  signal:int -> t -> Scheduler.t -> (bool -> unit) -> unit

(** Calls [send_signal] with [~signal:Sys.sigint] *)
val stop : ?maxattempts:int -> ?interval:Time.t -> t -> Scheduler.t ->
  (bool -> unit) -> unit

(** Calls [send_signal] with [~signal:Sys.sigkill] *)
val kill : ?maxattempts:int -> ?interval:Time.t -> t -> Scheduler.t ->
  (bool -> unit) -> unit

(** @return the pid of the given processus *)
val get_pid : t -> int
Something went wrong with that request. Please try again.