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

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

Issue 11260048: Look up executable on PATH when given environment variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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
« runtime/bin/process_linux.cc ('K') | « runtime/bin/process_linux.cc ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 <poll.h> 9 #include <poll.h>
10 #include <signal.h> 10 #include <signal.h>
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <stdlib.h> 12 #include <stdlib.h>
13 #include <string.h> 13 #include <string.h>
14 #include <unistd.h> 14 #include <unistd.h>
15 15
16 #include "bin/fdutils.h" 16 #include "bin/fdutils.h"
17 #include "bin/thread.h" 17 #include "bin/thread.h"
18 18
19 extern char **environ;
19 20
20 // ProcessInfo is used to map a process id to the file descriptor for 21 // ProcessInfo is used to map a process id to the file descriptor for
21 // the pipe used to communicate the exit code of the process to Dart. 22 // the pipe used to communicate the exit code of the process to Dart.
22 // ProcessInfo objects are kept in the static singly-linked 23 // ProcessInfo objects are kept in the static singly-linked
23 // ProcessInfoList. 24 // ProcessInfoList.
24 class ProcessInfo { 25 class ProcessInfo {
25 public: 26 public:
26 ProcessInfo(pid_t pid, intptr_t fd) : pid_(pid), fd_(fd) { } 27 ProcessInfo(pid_t pid, intptr_t fd) : pid_(pid), fd_(fd) { }
27 ~ProcessInfo() { 28 ~ProcessInfo() {
28 int closed = TEMP_FAILURE_RETRY(close(fd_)); 29 int closed = TEMP_FAILURE_RETRY(close(fd_));
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 if (TEMP_FAILURE_RETRY(dup2(read_err[1], STDERR_FILENO)) == -1) { 454 if (TEMP_FAILURE_RETRY(dup2(read_err[1], STDERR_FILENO)) == -1) {
454 ReportChildError(exec_control[1]); 455 ReportChildError(exec_control[1]);
455 } 456 }
456 TEMP_FAILURE_RETRY(close(read_err[1])); 457 TEMP_FAILURE_RETRY(close(read_err[1]));
457 458
458 if (working_directory != NULL && 459 if (working_directory != NULL &&
459 TEMP_FAILURE_RETRY(chdir(working_directory)) == -1) { 460 TEMP_FAILURE_RETRY(chdir(working_directory)) == -1) {
460 ReportChildError(exec_control[1]); 461 ReportChildError(exec_control[1]);
461 } 462 }
462 463
463 if (environment != NULL) { 464 char **orig_environ = environ;
464 TEMP_FAILURE_RETRY( 465 if (program_environment != NULL) {
465 execve(path, 466 environ = program_environment;
466 const_cast<char* const*>(program_arguments),
467 program_environment));
468 } else {
469 TEMP_FAILURE_RETRY(
470 execvp(path, const_cast<char* const*>(program_arguments)));
471 } 467 }
468 TEMP_FAILURE_RETRY(
469 execvp(path, const_cast<char* const*>(program_arguments)));
470 // Dead code, unless execvp fails.
471 environ = orig_environ;
472
472 ReportChildError(exec_control[1]); 473 ReportChildError(exec_control[1]);
473 } 474 }
474 475
475 // The arguments and environment for the spawned process are not needed 476 // The arguments and environment for the spawned process are not needed
476 // any longer. 477 // any longer.
477 delete[] program_arguments; 478 delete[] program_arguments;
478 delete[] program_environment; 479 delete[] program_environment;
479 480
480 int event_fds[2]; 481 int event_fds[2];
481 result = TEMP_FAILURE_RETRY(pipe(event_fds)); 482 result = TEMP_FAILURE_RETRY(pipe(event_fds));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 557
557 558
558 void Process::TerminateExitCodeHandler() { 559 void Process::TerminateExitCodeHandler() {
559 ExitCodeHandler::TerminateExitCodeThread(); 560 ExitCodeHandler::TerminateExitCodeThread();
560 } 561 }
561 562
562 563
563 intptr_t Process::CurrentProcessId() { 564 intptr_t Process::CurrentProcessId() {
564 return static_cast<intptr_t>(getpid()); 565 return static_cast<intptr_t>(getpid());
565 } 566 }
OLDNEW
« runtime/bin/process_linux.cc ('K') | « runtime/bin/process_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698