Chromium Code Reviews| 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 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 workingDirectory, | 64 workingDirectory, |
| 65 environment, | 65 environment, |
| 66 includeParentEnvironment, | 66 includeParentEnvironment, |
| 67 runInShell, | 67 runInShell, |
| 68 stdoutEncoding, | 68 stdoutEncoding, |
| 69 stderrEncoding); | 69 stderrEncoding); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 | 73 |
| 74 List<_SignalController> _signalControllers = new List(32); | |
| 75 | |
| 76 | |
| 77 class _SignalController { | |
| 78 final ProcessSignal signal; | |
| 79 | |
| 80 StreamController _controller; | |
| 81 var _id; | |
| 82 | |
| 83 _SignalController(this.signal) { | |
| 84 _controller = new StreamController.broadcast( | |
| 85 onListen: _listen, | |
| 86 onCancel: _cancel); | |
| 87 } | |
| 88 | |
| 89 Stream<ProcessSignal> get stream => _controller.stream; | |
| 90 | |
| 91 void _listen() { | |
| 92 var id = _setSignalHandler(signal._signalNumber); | |
| 93 if (id is! int) { | |
| 94 _controller.addError( | |
| 95 new SignalException("Failed to listen for $signal", id)); | |
| 96 return; | |
| 97 } | |
| 98 _id = id; | |
| 99 var socket = new _RawSocket(new _NativeSocket.watch(id)); | |
| 100 socket.listen((event) { | |
| 101 if (event == RawSocketEvent.READ) { | |
| 102 var bytes = socket.read(); | |
| 103 for (int i = 0; i < bytes.length; i++) { | |
| 104 _controller.add(signal); | |
| 105 } | |
| 106 } | |
| 107 }); | |
| 108 } | |
| 109 | |
| 110 void _cancel() { | |
| 111 if (_id != null) { | |
| 112 _clearSignalHandler(signal._signalNumber); | |
| 113 _id = null; | |
| 114 } | |
| 115 } | |
| 116 | |
| 117 /* patch */ static int _setSignalHandler(int signal) | |
| 118 native "Process_SetSignalHandler"; | |
| 119 /* patch */ static int _clearSignalHandler(int signal) | |
| 120 native "Process_ClearSignalHandler"; | |
| 121 } | |
| 122 | |
| 123 | |
| 74 patch class _ProcessUtils { | 124 patch class _ProcessUtils { |
| 75 /* patch */ static void _exit(int status) native "Process_Exit"; | 125 /* patch */ static void _exit(int status) native "Process_Exit"; |
| 76 /* patch */ static void _setExitCode(int status) | 126 /* patch */ static void _setExitCode(int status) |
| 77 native "Process_SetExitCode"; | 127 native "Process_SetExitCode"; |
| 78 /* patch */ static void _sleep(int millis) native "Process_Sleep"; | 128 /* patch */ static void _sleep(int millis) native "Process_Sleep"; |
| 79 /* patch */ static int _pid(Process process) native "Process_Pid"; | 129 /* patch */ static int _pid(Process process) native "Process_Pid"; |
| 130 /* patch */ static Stream<ProcessSignal> _watchSignal(ProcessSignal signal) { | |
| 131 if (signal != ProcessSignal.SIGHUP && | |
| 132 signal != ProcessSignal.SIGINT && | |
| 133 signal != ProcessSignal.SIGUSR1 && | |
| 134 signal != ProcessSignal.SIGUSR2 && | |
| 135 signal != ProcessSignal.SIGWINCH) { | |
|
Søren Gjesse
2013/12/18 08:07:14
Different set for Windows?
Anders Johnsen
2013/12/18 21:20:29
Done.
| |
| 136 throw new SignalException( | |
| 137 "It's not allowed to listen for $signal signals."); | |
|
Søren Gjesse
2013/12/18 08:07:14
"Listening for signal $signal is not supported"
Anders Johnsen
2013/12/18 21:20:29
Done.
| |
| 138 } | |
| 139 if (_signalControllers[signal._signalNumber] == null) { | |
| 140 _signalControllers[signal._signalNumber] = new _SignalController(signal); | |
| 141 } | |
| 142 return _signalControllers[signal._signalNumber].stream; | |
| 143 } | |
| 80 } | 144 } |
| 81 | 145 |
| 82 | 146 |
| 83 class _ProcessStartStatus { | 147 class _ProcessStartStatus { |
| 84 int _errorCode; // Set to OS error code if process start failed. | 148 int _errorCode; // Set to OS error code if process start failed. |
| 85 String _errorMessage; // Set to OS error message if process start failed. | 149 String _errorMessage; // Set to OS error message if process start failed. |
| 86 } | 150 } |
| 87 | 151 |
| 88 | 152 |
| 89 class _ProcessImpl extends NativeFieldWrapperClass1 implements Process { | 153 class _ProcessImpl extends NativeFieldWrapperClass1 implements Process { |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 const _ProcessResult(int this.pid, | 531 const _ProcessResult(int this.pid, |
| 468 int this.exitCode, | 532 int this.exitCode, |
| 469 this.stdout, | 533 this.stdout, |
| 470 this.stderr); | 534 this.stderr); |
| 471 | 535 |
| 472 final int pid; | 536 final int pid; |
| 473 final int exitCode; | 537 final int exitCode; |
| 474 final stdout; | 538 final stdout; |
| 475 final stderr; | 539 final stderr; |
| 476 } | 540 } |
| OLD | NEW |