Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / stubs / mlton-stubs / process.sig
1 (* Copyright (C) 2002-2006 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 *
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
6 *)
7
8 signature MLTON_PROCESS =
9 sig
10 type pid
11
12 (* Process handle *)
13 type ('stdin, 'stdout, 'stderr) t
14
15 (* is the io 'dir input or output *)
16 type input
17 type output
18
19 (* to what use can the stdio channel be put *)
20 type none (* it's not connected to a pipe *)
21 type chain (* connect one child to another *)
22 type any (* any use is allowed -- dangerous *)
23
24 exception MisuseOfForget (* you avoided the type safety and broke it *)
25 exception DoublyRedirected (* you tried to reuse a Param.child *)
26
27 structure Child:
28 sig
29 type ('use, 'dir) t
30
31 val binIn: (BinIO.instream, input) t -> BinIO.instream
32 val binOut: (BinIO.outstream, output) t -> BinIO.outstream
33 (* not necessarily available on all systems; may raise an exception *)
34 val fd: (Posix.FileSys.file_desc, 'dir) t -> Posix.FileSys.file_desc
35 (* used for situations where 'forget' was needed for arbitrary redir *)
36 val remember: (any, 'dir) t -> ('use, 'dir) t
37 val textIn: (TextIO.instream, input) t -> TextIO.instream
38 val textOut: (TextIO.outstream, output) t -> TextIO.outstream
39 end
40
41 structure Param:
42 sig
43 type ('use, 'dir) t
44
45 (* {child,fd} close their parameter when create is called.
46 * therefore they may only be used once!
47 *)
48 val child: (chain, 'dir) Child.t -> (none, 'dir) t
49 (* Not necessarily available on all systems; may raise an exception *)
50 val fd: Posix.FileSys.file_desc -> (none, 'dir) t
51 val file: string -> (none, 'dir) t
52 (* used if you want to return two posibilities; use with care *)
53 val forget: ('use, 'dir) t -> (any, 'dir) t
54 val null: (none, 'dir) t
55 val pipe: ('use, 'dir) t
56 val self: (none, 'dir) t
57 end
58
59 val create:
60 {args: string list,
61 env: string list option,
62 path: string,
63 stderr: ('stderr, output) Param.t,
64 stdin: ('stdin, input) Param.t,
65 stdout: ('stdout, output) Param.t}
66 -> ('stdin, 'stdout, 'stderr) t
67 val getStderr: ('stdin, 'stdout, 'stderr) t -> ('stderr, input) Child.t
68 val getStdin: ('stdin, 'stdout, 'stderr) t -> ('stdin, output) Child.t
69 val getStdout: ('stdin, 'stdout, 'stderr) t -> ('stdout, input) Child.t
70 val kill: ('stdin, 'stdout, 'stderr) t * Posix.Signal.signal -> unit
71 val reap: ('stdin, 'stdout, 'stderr) t -> Posix.Process.exit_status
72 val spawn: {args: string list, path: string} -> pid
73 val spawne: {args: string list, env: string list, path: string} -> pid
74 val spawnp: {file: string, args: string list} -> pid
75 end