Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: runtime/bin/process.cc

Issue 798743004: Add support for starting a detached process (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/process.h ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 return string_args; 59 return string_args;
60 } 60 }
61 61
62 void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) { 62 void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
63 Dart_Handle process = Dart_GetNativeArgument(args, 0); 63 Dart_Handle process = Dart_GetNativeArgument(args, 0);
64 intptr_t process_stdin; 64 intptr_t process_stdin;
65 intptr_t process_stdout; 65 intptr_t process_stdout;
66 intptr_t process_stderr; 66 intptr_t process_stderr;
67 intptr_t exit_event; 67 intptr_t exit_event;
68 Dart_Handle status_handle = Dart_GetNativeArgument(args, 9); 68 Dart_Handle status_handle = Dart_GetNativeArgument(args, 10);
69 Dart_Handle path_handle = Dart_GetNativeArgument(args, 1); 69 Dart_Handle path_handle = Dart_GetNativeArgument(args, 1);
70 // The Dart code verifies that the path implements the String 70 // The Dart code verifies that the path implements the String
71 // interface. However, only builtin Strings are handled by 71 // interface. However, only builtin Strings are handled by
72 // GetStringValue. 72 // GetStringValue.
73 if (!Dart_IsString(path_handle)) { 73 if (!Dart_IsString(path_handle)) {
74 DartUtils::SetIntegerField(status_handle, "_errorCode", 0); 74 DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
75 DartUtils::SetStringField( 75 DartUtils::SetStringField(
76 status_handle, "_errorMessage", "Path must be a builtin string"); 76 status_handle, "_errorMessage", "Path must be a builtin string");
77 Dart_SetReturnValue(args, Dart_NewBoolean(false)); 77 Dart_SetReturnValue(args, Dart_NewBoolean(false));
78 return; 78 return;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 Dart_Handle stdin_handle = Dart_GetNativeArgument(args, 5); 121 bool detached = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 5));
122 Dart_Handle stdout_handle = Dart_GetNativeArgument(args, 6); 122 Dart_Handle stdin_handle = Dart_GetNativeArgument(args, 6);
123 Dart_Handle stderr_handle = Dart_GetNativeArgument(args, 7); 123 Dart_Handle stdout_handle = Dart_GetNativeArgument(args, 7);
124 Dart_Handle exit_handle = Dart_GetNativeArgument(args, 8); 124 Dart_Handle stderr_handle = Dart_GetNativeArgument(args, 8);
125 Dart_Handle exit_handle = Dart_GetNativeArgument(args, 9);
125 intptr_t pid = -1; 126 intptr_t pid = -1;
126 char* os_error_message = NULL; 127 char* os_error_message = NULL;
127 128
128 int error_code = Process::Start(path, 129 int error_code = Process::Start(path,
129 string_args, 130 string_args,
130 args_length, 131 args_length,
131 working_directory, 132 working_directory,
132 string_environment, 133 string_environment,
133 environment_length, 134 environment_length,
135 detached,
134 &process_stdout, 136 &process_stdout,
135 &process_stdin, 137 &process_stdin,
136 &process_stderr, 138 &process_stderr,
137 &pid, 139 &pid,
138 &exit_event, 140 &exit_event,
139 &os_error_message); 141 &os_error_message);
140 if (error_code == 0) { 142 if (error_code == 0) {
141 Socket::SetSocketIdNativeField(stdin_handle, process_stdin); 143 if (!detached) {
142 Socket::SetSocketIdNativeField(stdout_handle, process_stdout); 144 Socket::SetSocketIdNativeField(stdin_handle, process_stdin);
143 Socket::SetSocketIdNativeField(stderr_handle, process_stderr); 145 Socket::SetSocketIdNativeField(stdout_handle, process_stdout);
144 Socket::SetSocketIdNativeField(exit_handle, exit_event); 146 Socket::SetSocketIdNativeField(stderr_handle, process_stderr);
147 Socket::SetSocketIdNativeField(exit_handle, exit_event);
148 }
145 Process::SetProcessIdNativeField(process, pid); 149 Process::SetProcessIdNativeField(process, pid);
146 } else { 150 } else {
147 DartUtils::SetIntegerField( 151 DartUtils::SetIntegerField(
148 status_handle, "_errorCode", error_code); 152 status_handle, "_errorCode", error_code);
149 DartUtils::SetStringField( 153 DartUtils::SetStringField(
150 status_handle, "_errorMessage", os_error_message); 154 status_handle, "_errorMessage", os_error_message);
151 } 155 }
152 delete[] string_args; 156 delete[] string_args;
153 delete[] string_environment; 157 delete[] string_environment;
154 free(os_error_message); 158 free(os_error_message);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 int external_length = strlen(system_string); 308 int external_length = strlen(system_string);
305 uint8_t* buffer = NULL; 309 uint8_t* buffer = NULL;
306 Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer); 310 Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer);
307 memmove(buffer, system_string, external_length); 311 memmove(buffer, system_string, external_length);
308 if (utf8 != system_string) free(const_cast<char*>(system_string)); 312 if (utf8 != system_string) free(const_cast<char*>(system_string));
309 Dart_SetReturnValue(args, external_array); 313 Dart_SetReturnValue(args, external_array);
310 } 314 }
311 315
312 } // namespace bin 316 } // namespace bin
313 } // namespace dart 317 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/process.h ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698