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

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

Issue 9108008: Add optional workingDirectory argument to Process.start. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/process.h" 5 #include "bin/process.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 exec_control_fd, os_error_message, strlen(os_error_message) + 1); 125 exec_control_fd, os_error_message, strlen(os_error_message) + 1);
126 } 126 }
127 close(exec_control_fd); 127 close(exec_control_fd);
128 exit(1); 128 exit(1);
129 } 129 }
130 130
131 131
132 int Process::Start(const char* path, 132 int Process::Start(const char* path,
133 char* arguments[], 133 char* arguments[],
134 intptr_t arguments_length, 134 intptr_t arguments_length,
135 const char* working_directory,
135 intptr_t* in, 136 intptr_t* in,
136 intptr_t* out, 137 intptr_t* out,
137 intptr_t* err, 138 intptr_t* err,
138 intptr_t* id, 139 intptr_t* id,
139 intptr_t* exit_event, 140 intptr_t* exit_event,
140 char* os_error_message, 141 char* os_error_message,
141 int os_error_message_len) { 142 int os_error_message_len) {
142 pid_t pid; 143 pid_t pid;
143 int read_in[2]; // Pipe for stdout to child process. 144 int read_in[2]; // Pipe for stdout to child process.
144 int read_err[2]; // Pipe for stderr to child process. 145 int read_err[2]; // Pipe for stderr to child process.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (dup2(read_in[1], STDOUT_FILENO) == -1) { 253 if (dup2(read_in[1], STDOUT_FILENO) == -1) {
253 ReportChildError(exec_control[1]); 254 ReportChildError(exec_control[1]);
254 } 255 }
255 close(read_in[1]); 256 close(read_in[1]);
256 257
257 if (dup2(read_err[1], STDERR_FILENO) == -1) { 258 if (dup2(read_err[1], STDERR_FILENO) == -1) {
258 ReportChildError(exec_control[1]); 259 ReportChildError(exec_control[1]);
259 } 260 }
260 close(read_err[1]); 261 close(read_err[1]);
261 262
263 if (working_directory != NULL && chdir(working_directory) == -1) {
264 ReportChildError(exec_control[1]);
265 }
266
262 execvp(path, const_cast<char* const*>(program_arguments)); 267 execvp(path, const_cast<char* const*>(program_arguments));
263 ReportChildError(exec_control[1]); 268 ReportChildError(exec_control[1]);
264 } 269 }
265 270
266 // The arguments for the spawned process are not needed any longer. 271 // The arguments for the spawned process are not needed any longer.
267 delete[] program_arguments; 272 delete[] program_arguments;
268 273
269 int event_fds[2]; 274 int event_fds[2];
270 result = pipe(event_fds); 275 result = pipe(event_fds);
271 if (result < 0) { 276 if (result < 0) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 if (result == -1) { 350 if (result == -1) {
346 return false; 351 return false;
347 } 352 }
348 return true; 353 return true;
349 } 354 }
350 355
351 356
352 void Process::Exit(intptr_t id) { 357 void Process::Exit(intptr_t id) {
353 RemoveProcess(id); 358 RemoveProcess(id);
354 } 359 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698