Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | (* Copyright (C) 2002-2007 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 | val spawn: {args: string list, path: string} -> pid | |
13 | val spawne: {args: string list, env: string list, path: string} -> pid | |
14 | val spawnp: {file: string, args: string list} -> pid | |
15 | ||
16 | (* Process handle *) | |
17 | type ('stdin, 'stdout, 'stderr) t | |
18 | ||
19 | (* is the io 'dir input or output *) | |
20 | type input | |
21 | type output | |
22 | ||
23 | (* to what use can the stdio channel be put *) | |
24 | type none (* it's not connected to a pipe *) | |
25 | type chain (* connect one child to another *) | |
26 | type any (* any use is allowed -- dangerous *) | |
27 | ||
28 | exception MisuseOfForget (* you avoided the type safety and broke it *) | |
29 | exception DoublyRedirected (* you tried to reuse a Param.child *) | |
30 | ||
31 | structure Child: | |
32 | sig | |
33 | type ('use, 'dir) t | |
34 | ||
35 | val binIn: (BinIO.instream, input) t -> BinIO.instream | |
36 | val binOut: (BinIO.outstream, output) t -> BinIO.outstream | |
37 | (* not necessarily available on all systems; may raise an exception *) | |
38 | val fd: (Posix.FileSys.file_desc, 'dir) t -> Posix.FileSys.file_desc | |
39 | (* used for situations where 'forget' was needed for arbitrary redir *) | |
40 | val remember: (any, 'dir) t -> ('use, 'dir) t | |
41 | val textIn: (TextIO.instream, input) t -> TextIO.instream | |
42 | val textOut: (TextIO.outstream, output) t -> TextIO.outstream | |
43 | end | |
44 | ||
45 | structure Param: | |
46 | sig | |
47 | type ('use, 'dir) t | |
48 | ||
49 | (* {child,fd} close their parameter when create is called. | |
50 | * therefore they may only be used once! | |
51 | *) | |
52 | val child: (chain, 'dir) Child.t -> (none, 'dir) t | |
53 | (* Not necessarily available on all systems; may raise an exception *) | |
54 | val fd: Posix.FileSys.file_desc -> (none, 'dir) t | |
55 | val file: string -> (none, 'dir) t | |
56 | (* used if you want to return two posibilities; use with care *) | |
57 | val forget: ('use, 'dir) t -> (any, 'dir) t | |
58 | val null: (none, 'dir) t | |
59 | val pipe: ('use, 'dir) t | |
60 | val self: (none, 'dir) t | |
61 | end | |
62 | ||
63 | val create: | |
64 | {args: string list, | |
65 | env: string list option, | |
66 | path: string, | |
67 | stderr: ('stderr, output) Param.t, | |
68 | stdin: ('stdin, input) Param.t, | |
69 | stdout: ('stdout, output) Param.t} | |
70 | -> ('stdin, 'stdout, 'stderr) t | |
71 | val getStderr: ('stdin, 'stdout, 'stderr) t -> ('stderr, input) Child.t | |
72 | val getStdin: ('stdin, 'stdout, 'stderr) t -> ('stdin, output) Child.t | |
73 | val getStdout: ('stdin, 'stdout, 'stderr) t -> ('stdout, input) Child.t | |
74 | val kill: ('stdin, 'stdout, 'stderr) t * Posix.Signal.signal -> unit | |
75 | val reap: ('stdin, 'stdout, 'stderr) t -> Posix.Process.exit_status | |
76 | end |