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 #include "bin/dartutils.h" | 5 #include "bin/dartutils.h" |
| 6 #include "bin/io_buffer.h" | 6 #include "bin/io_buffer.h" |
| 7 #include "bin/platform.h" | 7 #include "bin/platform.h" |
| 8 #include "bin/process.h" | 8 #include "bin/process.h" |
| 9 #include "bin/socket.h" | 9 #include "bin/socket.h" |
| 10 | 10 |
| 11 #include "include/dart_api.h" | 11 #include "include/dart_api.h" |
| 12 | 12 #include "include/dart_native_api.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 namespace bin { | 15 namespace bin { |
| 16 | 16 |
| 17 static const int kProcessIdNativeField = 0; | 17 static const int kProcessIdNativeField = 0; |
| 18 | 18 |
| 19 int Process::global_exit_code_ = 0; | 19 int Process::global_exit_code_ = 0; |
| 20 dart::Mutex* Process::global_exit_code_mutex_ = new dart::Mutex(); | 20 dart::Mutex* Process::global_exit_code_mutex_ = new dart::Mutex(); |
| 21 | 21 |
| 22 // Extract an array of C strings from a list of Dart strings. | 22 // Extract an array of C strings from a list of Dart strings. |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 intptr_t signal = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2)); | 201 intptr_t signal = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2)); |
| 202 bool success = Process::Kill(pid, signal); | 202 bool success = Process::Kill(pid, signal); |
| 203 Dart_SetReturnValue(args, Dart_NewBoolean(success)); | 203 Dart_SetReturnValue(args, Dart_NewBoolean(success)); |
| 204 } | 204 } |
| 205 | 205 |
| 206 | 206 |
| 207 void FUNCTION_NAME(Process_Exit)(Dart_NativeArguments args) { | 207 void FUNCTION_NAME(Process_Exit)(Dart_NativeArguments args) { |
| 208 int64_t status = 0; | 208 int64_t status = 0; |
| 209 // Ignore result if passing invalid argument and just exit 0. | 209 // Ignore result if passing invalid argument and just exit 0. |
| 210 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &status); | 210 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &status); |
| 211 // On Windows we must shut down the thread interrupter before exiting, | |
| 212 // otherwise we may end up with a suspended thread and hung process. | |
| 213 Dart_ShutdownThreadInterrupter(); | |
|
siva
2013/12/13 21:29:14
Could we just call Dart_Cleanup() here, that would
Cutch
2013/12/13 22:40:18
Done.
| |
| 211 // Be sure to do platform-specific cleanups. | 214 // Be sure to do platform-specific cleanups. |
| 212 Platform::Cleanup(); | 215 Platform::Cleanup(); |
| 213 exit(static_cast<int>(status)); | 216 exit(static_cast<int>(status)); |
| 214 } | 217 } |
| 215 | 218 |
| 216 | 219 |
| 217 void FUNCTION_NAME(Process_SetExitCode)(Dart_NativeArguments args) { | 220 void FUNCTION_NAME(Process_SetExitCode)(Dart_NativeArguments args) { |
| 218 int64_t status = 0; | 221 int64_t status = 0; |
| 219 // Ignore result if passing invalid argument and just set exit code to 0. | 222 // Ignore result if passing invalid argument and just set exit code to 0. |
| 220 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &status); | 223 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &status); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 int external_length = strlen(system_string); | 284 int external_length = strlen(system_string); |
| 282 uint8_t* buffer = NULL; | 285 uint8_t* buffer = NULL; |
| 283 Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer); | 286 Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer); |
| 284 memmove(buffer, system_string, external_length); | 287 memmove(buffer, system_string, external_length); |
| 285 if (utf8 != system_string) free(const_cast<char*>(system_string)); | 288 if (utf8 != system_string) free(const_cast<char*>(system_string)); |
| 286 Dart_SetReturnValue(args, external_array); | 289 Dart_SetReturnValue(args, external_array); |
| 287 } | 290 } |
| 288 | 291 |
| 289 } // namespace bin | 292 } // namespace bin |
| 290 } // namespace dart | 293 } // namespace dart |
| OLD | NEW |