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