Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 61 lines (44 sloc) 2.348 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18
19 (** Module to manage a single process
20
21 @author Mathieu Baudet
22 @author Hugo Venturini
23 *)
24
25 (** Type of a process *)
26 type t
27
28
29 type chans = {
30 p_stdin : Unix.file_descr;
31 p_stdout : Unix.file_descr;
32 p_stderr : Unix.file_descr;
33 }
34
35
36 (** 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.
37 @return the running process and channels to communicate with it
38 *)
39 val start : exec_name:string -> options:string list -> t * chans
40
41 (** Creates a [t] from a given pid *)
42 val recover_from_pid : exec_name:string -> options:string list -> int -> t
43
44 (** [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.
45 @param maxattempt number of attempts to send the signal, default is 3
46 @param interval time between to attempt to send the signal, default is 2 sec.
47 *)
48 val send_signal : ?maxattempts:int -> ?interval:Time.t ->
49 signal:int -> t -> Scheduler.t -> (bool -> unit) -> unit
50
51 (** Calls [send_signal] with [~signal:Sys.sigint] *)
52 val stop : ?maxattempts:int -> ?interval:Time.t -> t -> Scheduler.t ->
53 (bool -> unit) -> unit
54
55 (** Calls [send_signal] with [~signal:Sys.sigkill] *)
56 val kill : ?maxattempts:int -> ?interval:Time.t -> t -> Scheduler.t ->
57 (bool -> unit) -> unit
58
59 (** @return the pid of the given processus *)
60 val get_pid : t -> int
Something went wrong with that request. Please try again.