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

Side by Side Diff: base/process_util_posix.cc

Issue 200007: When forking, restore the default exception handler port.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | « base/process_util_mac.mm ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <dirent.h> 5 #include <dirent.h>
6 #include <errno.h> 6 #include <errno.h>
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <signal.h> 8 #include <signal.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <sys/resource.h> 10 #include <sys/resource.h>
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 bool LaunchApp(const std::vector<std::string>& argv, 226 bool LaunchApp(const std::vector<std::string>& argv,
227 const environment_vector& environ, 227 const environment_vector& environ,
228 const file_handle_mapping_vector& fds_to_remap, 228 const file_handle_mapping_vector& fds_to_remap,
229 bool wait, ProcessHandle* process_handle) { 229 bool wait, ProcessHandle* process_handle) {
230 pid_t pid = fork(); 230 pid_t pid = fork();
231 if (pid < 0) 231 if (pid < 0)
232 return false; 232 return false;
233 233
234 if (pid == 0) { 234 if (pid == 0) {
235 // Child process 235 // Child process
236 #if defined(OS_MACOSX)
237 RestoreDefaultExceptionHandler();
238 #endif
239
236 InjectiveMultimap fd_shuffle; 240 InjectiveMultimap fd_shuffle;
237 for (file_handle_mapping_vector::const_iterator 241 for (file_handle_mapping_vector::const_iterator
238 it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) { 242 it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) {
239 fd_shuffle.push_back(InjectionArc(it->first, it->second, false)); 243 fd_shuffle.push_back(InjectionArc(it->first, it->second, false));
240 } 244 }
241 245
242 for (environment_vector::const_iterator it = environ.begin(); 246 for (environment_vector::const_iterator it = environ.begin();
243 it != environ.end(); ++it) { 247 it != environ.end(); ++it) {
244 if (it->first) { 248 if (it->first) {
245 if (it->second) { 249 if (it->second) {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 if (pipe(pipe_fd) < 0) 517 if (pipe(pipe_fd) < 0)
514 return false; 518 return false;
515 519
516 switch (pid = fork()) { 520 switch (pid = fork()) {
517 case -1: // error 521 case -1: // error
518 close(pipe_fd[0]); 522 close(pipe_fd[0]);
519 close(pipe_fd[1]); 523 close(pipe_fd[1]);
520 return false; 524 return false;
521 case 0: // child 525 case 0: // child
522 { 526 {
527 #if defined(OS_MACOSX)
528 RestoreDefaultExceptionHandler();
529 #endif
530
523 // Obscure fork() rule: in the child, if you don't end up doing exec*(), 531 // Obscure fork() rule: in the child, if you don't end up doing exec*(),
524 // you call _exit() instead of exit(). This is because _exit() does not 532 // you call _exit() instead of exit(). This is because _exit() does not
525 // call any previously-registered (in the parent) exit handlers, which 533 // call any previously-registered (in the parent) exit handlers, which
526 // might do things like block waiting for threads that don't even exist 534 // might do things like block waiting for threads that don't even exist
527 // in the child. 535 // in the child.
528 int dev_null = open("/dev/null", O_WRONLY); 536 int dev_null = open("/dev/null", O_WRONLY);
529 if (dev_null < 0) 537 if (dev_null < 0)
530 _exit(127); 538 _exit(127);
531 539
532 InjectiveMultimap fd_shuffle; 540 InjectiveMultimap fd_shuffle;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 const ProcessFilter* filter) { 635 const ProcessFilter* filter) {
628 bool exited_cleanly = 636 bool exited_cleanly =
629 WaitForProcessesToExit(executable_name, wait_milliseconds, 637 WaitForProcessesToExit(executable_name, wait_milliseconds,
630 filter); 638 filter);
631 if (!exited_cleanly) 639 if (!exited_cleanly)
632 KillProcesses(executable_name, exit_code, filter); 640 KillProcesses(executable_name, exit_code, filter);
633 return exited_cleanly; 641 return exited_cleanly;
634 } 642 }
635 643
636 } // namespace base 644 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698