OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 [DartPackage="mojo_services"] | |
6 module native_support; | |
7 | |
8 import "files/interfaces/file.mojom"; | |
9 import "files/interfaces/types.mojom"; | |
10 | |
11 // Interface for dealing with (e.g., starting) "native" processes. | |
12 interface Process { | |
13 // Spawns a process, optionally redirecting stdin/stdout/stderr from/to the | |
14 // corresponding |mojo.files.File| (if null, redirects from/to /dev/null). | |
15 // |path| is the path to the binary to execute; |argv| is the argv to give to | |
16 // the process (if null, it just takes |argv[0]| to be |path| with no other | |
17 // arguments); |envp| is the environment to give to the process, consisting of | |
18 // an array of strings of the form "NAME=value" (if null, simply inherits the | |
19 // environment from the parent, whatever that is). | |
20 // TODO(vtl): This should really take an array of |mojo.files.File|s (or maybe | |
21 // two, one for input and the other for output), corresponding to FDs, but the | |
22 // C++ bindings generator doesn't support arrays of interfaces yet | |
23 // (https://github.com/domokit/mojo/issues/412). | |
24 // TODO(vtl): The implementation currently ignores |argv[0]| and always fills | |
25 // it in with |path|. | |
26 // TODO(vtl): Inheriting |envp| from the parent is somewhat dubious, and | |
27 // there's also no way to just specify modifications or limit inheritance. | |
28 Spawn(string path, | |
29 array<string>? argv, | |
30 array<string>? envp, | |
31 mojo.files.File? stdin_file, | |
32 mojo.files.File? stdout_file, | |
33 mojo.files.File? stderr_file, | |
34 ProcessController& process_controller) => (mojo.files.Error error); | |
35 // Like |Spawn()|, except that the child's stdin/stdout/stderr are redirected | |
36 // from/to |terminal_file|, which should be a |mojo.files.File| for a terminal | |
37 // (i.e., one that behaves like one, including responding to the required | |
38 // ioctls). | |
39 SpawnWithTerminal( | |
40 string path, | |
41 array<string>? argv, | |
42 array<string>? envp, | |
43 mojo.files.File terminal_file, | |
44 ProcessController& process_controller) => (mojo.files.Error error); | |
45 }; | |
46 | |
47 // Interface for controlling a process started by one of |Process|'s facilities | |
48 // (in particular, |Spawn()| or |SpawnWithTerminal()|). | |
49 // TODO(vtl): What does it do if this is closed (without being detached)? Kill | |
50 // with SIGHUP? | |
51 interface ProcessController { | |
52 // Wait for process completion. | |
53 // TODO(vtl): Add options (e.g., timeout)? | |
54 Wait() => (mojo.files.Error error, int32 exit_status); | |
55 | |
56 // Kill the process with the given signal (note: does not wait). |signal| | |
57 // should be nonnegative. This is not valid after a successful call to | |
58 // |Wait()|. | |
59 // TODO(vtl): Add constants for signals. (For standard POSIX signals, the | |
60 // values should be the same as the POSIX-specified values, so using POSIX | |
61 // macros for the values should always be OK.) | |
62 Kill(int32 signal) => (mojo.files.Error error); | |
63 | |
64 // TODO(vtl): Add a "Detach()"? | |
65 }; | |
OLD | NEW |