| 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 #include "bin/utils.h" | 10 #include "bin/utils.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 ExtractCStringList(environment, | 111 ExtractCStringList(environment, |
| 112 status_handle, | 112 status_handle, |
| 113 "Environment values must be builtin strings", | 113 "Environment values must be builtin strings", |
| 114 &environment_length); | 114 &environment_length); |
| 115 if (string_environment == NULL) { | 115 if (string_environment == NULL) { |
| 116 delete[] string_args; | 116 delete[] string_args; |
| 117 Dart_SetReturnValue(args, Dart_NewBoolean(false)); | 117 Dart_SetReturnValue(args, Dart_NewBoolean(false)); |
| 118 return; | 118 return; |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 bool detached = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 5)); | 121 int64_t mode = |
| 122 DartUtils::GetInt64ValueCheckRange(Dart_GetNativeArgument(args, 5), 0, 2); |
| 122 Dart_Handle stdin_handle = Dart_GetNativeArgument(args, 6); | 123 Dart_Handle stdin_handle = Dart_GetNativeArgument(args, 6); |
| 123 Dart_Handle stdout_handle = Dart_GetNativeArgument(args, 7); | 124 Dart_Handle stdout_handle = Dart_GetNativeArgument(args, 7); |
| 124 Dart_Handle stderr_handle = Dart_GetNativeArgument(args, 8); | 125 Dart_Handle stderr_handle = Dart_GetNativeArgument(args, 8); |
| 125 Dart_Handle exit_handle = Dart_GetNativeArgument(args, 9); | 126 Dart_Handle exit_handle = Dart_GetNativeArgument(args, 9); |
| 126 intptr_t pid = -1; | 127 intptr_t pid = -1; |
| 127 char* os_error_message = NULL; | 128 char* os_error_message = NULL; |
| 128 | 129 |
| 129 int error_code = Process::Start(path, | 130 int error_code = Process::Start(path, |
| 130 string_args, | 131 string_args, |
| 131 args_length, | 132 args_length, |
| 132 working_directory, | 133 working_directory, |
| 133 string_environment, | 134 string_environment, |
| 134 environment_length, | 135 environment_length, |
| 135 detached, | 136 static_cast<ProcessStartMode>(mode), |
| 136 &process_stdout, | 137 &process_stdout, |
| 137 &process_stdin, | 138 &process_stdin, |
| 138 &process_stderr, | 139 &process_stderr, |
| 139 &pid, | 140 &pid, |
| 140 &exit_event, | 141 &exit_event, |
| 141 &os_error_message); | 142 &os_error_message); |
| 142 if (error_code == 0) { | 143 if (error_code == 0) { |
| 143 if (!detached) { | 144 if (mode != kDetached) { |
| 144 Socket::SetSocketIdNativeField(stdin_handle, process_stdin); | 145 Socket::SetSocketIdNativeField(stdin_handle, process_stdin); |
| 145 Socket::SetSocketIdNativeField(stdout_handle, process_stdout); | 146 Socket::SetSocketIdNativeField(stdout_handle, process_stdout); |
| 146 Socket::SetSocketIdNativeField(stderr_handle, process_stderr); | 147 Socket::SetSocketIdNativeField(stderr_handle, process_stderr); |
| 148 } |
| 149 if (mode == kNormal) { |
| 147 Socket::SetSocketIdNativeField(exit_handle, exit_event); | 150 Socket::SetSocketIdNativeField(exit_handle, exit_event); |
| 148 } | 151 } |
| 149 Process::SetProcessIdNativeField(process, pid); | 152 Process::SetProcessIdNativeField(process, pid); |
| 150 } else { | 153 } else { |
| 151 DartUtils::SetIntegerField( | 154 DartUtils::SetIntegerField( |
| 152 status_handle, "_errorCode", error_code); | 155 status_handle, "_errorCode", error_code); |
| 153 DartUtils::SetStringField( | 156 DartUtils::SetStringField( |
| 154 status_handle, | 157 status_handle, |
| 155 "_errorMessage", | 158 "_errorMessage", |
| 156 os_error_message != NULL ? os_error_message | 159 os_error_message != NULL ? os_error_message |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 int external_length = strlen(system_string); | 314 int external_length = strlen(system_string); |
| 312 uint8_t* buffer = NULL; | 315 uint8_t* buffer = NULL; |
| 313 Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer); | 316 Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer); |
| 314 memmove(buffer, system_string, external_length); | 317 memmove(buffer, system_string, external_length); |
| 315 if (utf8 != system_string) free(const_cast<char*>(system_string)); | 318 if (utf8 != system_string) free(const_cast<char*>(system_string)); |
| 316 Dart_SetReturnValue(args, external_array); | 319 Dart_SetReturnValue(args, external_array); |
| 317 } | 320 } |
| 318 | 321 |
| 319 } // namespace bin | 322 } // namespace bin |
| 320 } // namespace dart | 323 } // namespace dart |
| OLD | NEW |