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

Side by Side Diff: runtime/bin/process_linux.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: Remove dead code and add tests. 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
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 <sys/wait.h> 14 #include <sys/wait.h>
15 #include <unistd.h> 15 #include <unistd.h>
16 16
17 #include "bin/fdutils.h" 17 #include "bin/fdutils.h"
18 #include "bin/thread.h" 18 #include "bin/thread.h"
19 19
20 extern char **environ;
20 21
21 // ProcessInfo is used to map a process id to the file descriptor for 22 // ProcessInfo is used to map a process id to the file descriptor for
22 // the pipe used to communicate the exit code of the process to Dart. 23 // the pipe used to communicate the exit code of the process to Dart.
23 // ProcessInfo objects are kept in the static singly-linked 24 // ProcessInfo objects are kept in the static singly-linked
24 // ProcessInfoList. 25 // ProcessInfoList.
25 class ProcessInfo { 26 class ProcessInfo {
26 public: 27 public:
27 ProcessInfo(pid_t pid, intptr_t fd) : pid_(pid), fd_(fd) { } 28 ProcessInfo(pid_t pid, intptr_t fd) : pid_(pid), fd_(fd) { }
28 ~ProcessInfo() { 29 ~ProcessInfo() {
29 int closed = TEMP_FAILURE_RETRY(close(fd_)); 30 int closed = TEMP_FAILURE_RETRY(close(fd_));
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 if (TEMP_FAILURE_RETRY(dup2(read_err[1], STDERR_FILENO)) == -1) { 455 if (TEMP_FAILURE_RETRY(dup2(read_err[1], STDERR_FILENO)) == -1) {
455 ReportChildError(exec_control[1]); 456 ReportChildError(exec_control[1]);
456 } 457 }
457 TEMP_FAILURE_RETRY(close(read_err[1])); 458 TEMP_FAILURE_RETRY(close(read_err[1]));
458 459
459 if (working_directory != NULL && 460 if (working_directory != NULL &&
460 TEMP_FAILURE_RETRY(chdir(working_directory)) == -1) { 461 TEMP_FAILURE_RETRY(chdir(working_directory)) == -1) {
461 ReportChildError(exec_control[1]); 462 ReportChildError(exec_control[1]);
462 } 463 }
463 464
464 if (environment != NULL) { 465 if (program_environment != NULL) {
465 TEMP_FAILURE_RETRY( 466 environ = program_environment;
466 execve(path,
467 const_cast<char* const*>(program_arguments),
468 program_environment));
469 } else {
470 TEMP_FAILURE_RETRY(
471 execvp(path, const_cast<char* const*>(program_arguments)));
472 } 467 }
468
469 TEMP_FAILURE_RETRY(
470 execvp(path, const_cast<char* const*>(program_arguments)));
471
473 ReportChildError(exec_control[1]); 472 ReportChildError(exec_control[1]);
474 } 473 }
475 474
476 // The arguments and environment for the spawned process are not needed 475 // The arguments and environment for the spawned process are not needed
477 // any longer. 476 // any longer.
478 delete[] program_arguments; 477 delete[] program_arguments;
479 delete[] program_environment; 478 delete[] program_environment;
480 479
481 int event_fds[2]; 480 int event_fds[2];
482 result = TEMP_FAILURE_RETRY(pipe(event_fds)); 481 result = TEMP_FAILURE_RETRY(pipe(event_fds));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 556
558 557
559 void Process::TerminateExitCodeHandler() { 558 void Process::TerminateExitCodeHandler() {
560 ExitCodeHandler::TerminateExitCodeThread(); 559 ExitCodeHandler::TerminateExitCodeThread();
561 } 560 }
562 561
563 562
564 intptr_t Process::CurrentProcessId() { 563 intptr_t Process::CurrentProcessId() {
565 return static_cast<intptr_t>(getpid()); 564 return static_cast<intptr_t>(getpid());
566 } 565 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/process_macos.cc » ('j') | tests/standalone/io/process_path_environment_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698