OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 @patch class _WindowsCodePageDecoder { | 5 @patch class _WindowsCodePageDecoder { |
6 /* @patch */ static String _decodeBytes(List<int> bytes) | 6 @patch static String _decodeBytes(List<int> bytes) |
7 native "SystemEncodingToString"; | 7 native "SystemEncodingToString"; |
8 } | 8 } |
9 | 9 |
10 | 10 |
11 @patch class _WindowsCodePageEncoder { | 11 @patch class _WindowsCodePageEncoder { |
12 /* @patch */ static List<int> _encodeString(String string) | 12 @patch static List<int> _encodeString(String string) |
13 native "StringToSystemEncoding"; | 13 native "StringToSystemEncoding"; |
14 } | 14 } |
15 | 15 |
16 | 16 |
17 @patch class Process { | 17 @patch class Process { |
18 /* @patch */ static Future<Process> start( | 18 @patch static Future<Process> start( |
19 String executable, | 19 String executable, |
20 List<String> arguments, | 20 List<String> arguments, |
21 {String workingDirectory, | 21 {String workingDirectory, |
22 Map<String, String> environment, | 22 Map<String, String> environment, |
23 bool includeParentEnvironment: true, | 23 bool includeParentEnvironment: true, |
24 bool runInShell: false, | 24 bool runInShell: false, |
25 ProcessStartMode mode: ProcessStartMode.NORMAL}) { | 25 ProcessStartMode mode: ProcessStartMode.NORMAL}) { |
26 _ProcessImpl process = new _ProcessImpl(executable, | 26 _ProcessImpl process = new _ProcessImpl(executable, |
27 arguments, | 27 arguments, |
28 workingDirectory, | 28 workingDirectory, |
29 environment, | 29 environment, |
30 includeParentEnvironment, | 30 includeParentEnvironment, |
31 runInShell, | 31 runInShell, |
32 mode); | 32 mode); |
33 return process._start(); | 33 return process._start(); |
34 } | 34 } |
35 | 35 |
36 /* @patch */ static Future<ProcessResult> run( | 36 @patch static Future<ProcessResult> run( |
37 String executable, | 37 String executable, |
38 List<String> arguments, | 38 List<String> arguments, |
39 {String workingDirectory, | 39 {String workingDirectory, |
40 Map<String, String> environment, | 40 Map<String, String> environment, |
41 bool includeParentEnvironment: true, | 41 bool includeParentEnvironment: true, |
42 bool runInShell: false, | 42 bool runInShell: false, |
43 Encoding stdoutEncoding: SYSTEM_ENCODING, | 43 Encoding stdoutEncoding: SYSTEM_ENCODING, |
44 Encoding stderrEncoding: SYSTEM_ENCODING}) { | 44 Encoding stderrEncoding: SYSTEM_ENCODING}) { |
45 return _runNonInteractiveProcess(executable, | 45 return _runNonInteractiveProcess(executable, |
46 arguments, | 46 arguments, |
47 workingDirectory, | 47 workingDirectory, |
48 environment, | 48 environment, |
49 includeParentEnvironment, | 49 includeParentEnvironment, |
50 runInShell, | 50 runInShell, |
51 stdoutEncoding, | 51 stdoutEncoding, |
52 stderrEncoding); | 52 stderrEncoding); |
53 } | 53 } |
54 | 54 |
55 /* @patch */ static ProcessResult runSync( | 55 @patch static ProcessResult runSync( |
56 String executable, | 56 String executable, |
57 List<String> arguments, | 57 List<String> arguments, |
58 {String workingDirectory, | 58 {String workingDirectory, |
59 Map<String, String> environment, | 59 Map<String, String> environment, |
60 bool includeParentEnvironment: true, | 60 bool includeParentEnvironment: true, |
61 bool runInShell: false, | 61 bool runInShell: false, |
62 Encoding stdoutEncoding: SYSTEM_ENCODING, | 62 Encoding stdoutEncoding: SYSTEM_ENCODING, |
63 Encoding stderrEncoding: SYSTEM_ENCODING}) { | 63 Encoding stderrEncoding: SYSTEM_ENCODING}) { |
64 return _runNonInteractiveProcessSync(executable, | 64 return _runNonInteractiveProcessSync(executable, |
65 arguments, | 65 arguments, |
66 workingDirectory, | 66 workingDirectory, |
67 environment, | 67 environment, |
68 includeParentEnvironment, | 68 includeParentEnvironment, |
69 runInShell, | 69 runInShell, |
70 stdoutEncoding, | 70 stdoutEncoding, |
71 stderrEncoding); | 71 stderrEncoding); |
72 } | 72 } |
73 | 73 |
74 /* @patch */ static bool killPid( | 74 @patch static bool killPid( |
75 int pid, [ProcessSignal signal = ProcessSignal.SIGTERM]) { | 75 int pid, [ProcessSignal signal = ProcessSignal.SIGTERM]) { |
76 if (signal is! ProcessSignal) { | 76 if (signal is! ProcessSignal) { |
77 throw new ArgumentError( | 77 throw new ArgumentError( |
78 "Argument 'signal' must be a ProcessSignal"); | 78 "Argument 'signal' must be a ProcessSignal"); |
79 } | 79 } |
80 return _ProcessUtils._killPid(pid, signal._signalNumber); | 80 return _ProcessUtils._killPid(pid, signal._signalNumber); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 | 84 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 }); | 118 }); |
119 } | 119 } |
120 | 120 |
121 void _cancel() { | 121 void _cancel() { |
122 if (_id != null) { | 122 if (_id != null) { |
123 _clearSignalHandler(signal._signalNumber); | 123 _clearSignalHandler(signal._signalNumber); |
124 _id = null; | 124 _id = null; |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 /* @patch */ static _setSignalHandler(int signal) | 128 @patch static _setSignalHandler(int signal) |
129 native "Process_SetSignalHandler"; | 129 native "Process_SetSignalHandler"; |
130 /* @patch */ static int _clearSignalHandler(int signal) | 130 @patch static int _clearSignalHandler(int signal) |
131 native "Process_ClearSignalHandler"; | 131 native "Process_ClearSignalHandler"; |
132 } | 132 } |
133 | 133 |
134 Function _getWatchSignalInternal() => _ProcessUtils._watchSignalInternal; | 134 Function _getWatchSignalInternal() => _ProcessUtils._watchSignalInternal; |
135 | 135 |
136 | 136 |
137 @patch class _ProcessUtils { | 137 @patch class _ProcessUtils { |
138 /* @patch */ static void _exit(int status) native "Process_Exit"; | 138 @patch static void _exit(int status) native "Process_Exit"; |
139 /* @patch */ static void _setExitCode(int status) | 139 @patch static void _setExitCode(int status) |
140 native "Process_SetExitCode"; | 140 native "Process_SetExitCode"; |
141 /* @patch */ static int _getExitCode() native "Process_GetExitCode"; | 141 @patch static int _getExitCode() native "Process_GetExitCode"; |
142 /* @patch */ static void _sleep(int millis) native "Process_Sleep"; | 142 @patch static void _sleep(int millis) native "Process_Sleep"; |
143 /* @patch */ static int _pid(Process process) native "Process_Pid"; | 143 @patch static int _pid(Process process) native "Process_Pid"; |
144 static bool _killPid(int pid, int signal) | 144 static bool _killPid(int pid, int signal) |
145 native "Process_KillPid"; | 145 native "Process_KillPid"; |
146 /* @patch */ static Stream<ProcessSignal> _watchSignal(ProcessSignal signal) { | 146 @patch static Stream<ProcessSignal> _watchSignal(ProcessSignal signal) { |
147 if (signal != ProcessSignal.SIGHUP && | 147 if (signal != ProcessSignal.SIGHUP && |
148 signal != ProcessSignal.SIGINT && | 148 signal != ProcessSignal.SIGINT && |
149 signal != ProcessSignal.SIGTERM && | 149 signal != ProcessSignal.SIGTERM && |
150 (Platform.isWindows || | 150 (Platform.isWindows || |
151 (signal != ProcessSignal.SIGUSR1 && | 151 (signal != ProcessSignal.SIGUSR1 && |
152 signal != ProcessSignal.SIGUSR2 && | 152 signal != ProcessSignal.SIGUSR2 && |
153 signal != ProcessSignal.SIGWINCH))) { | 153 signal != ProcessSignal.SIGWINCH))) { |
154 throw new SignalException( | 154 throw new SignalException( |
155 "Listening for signal $signal is not supported"); | 155 "Listening for signal $signal is not supported"); |
156 } | 156 } |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 Encoding stderrEncoding) { | 595 Encoding stderrEncoding) { |
596 var process = new _ProcessImpl(executable, | 596 var process = new _ProcessImpl(executable, |
597 arguments, | 597 arguments, |
598 workingDirectory, | 598 workingDirectory, |
599 environment, | 599 environment, |
600 includeParentEnvironment, | 600 includeParentEnvironment, |
601 runInShell, | 601 runInShell, |
602 ProcessStartMode.NORMAL); | 602 ProcessStartMode.NORMAL); |
603 return process._runAndWait(stdoutEncoding, stderrEncoding); | 603 return process._runAndWait(stdoutEncoding, stderrEncoding); |
604 } | 604 } |
OLD | NEW |