OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 15 matching lines...) Expand all Loading... | |
26 #include "base/files/dir_reader_posix.h" | 26 #include "base/files/dir_reader_posix.h" |
27 #include "base/logging.h" | 27 #include "base/logging.h" |
28 #include "base/memory/scoped_ptr.h" | 28 #include "base/memory/scoped_ptr.h" |
29 #include "base/process_util.h" | 29 #include "base/process_util.h" |
30 #include "base/stringprintf.h" | 30 #include "base/stringprintf.h" |
31 #include "base/synchronization/waitable_event.h" | 31 #include "base/synchronization/waitable_event.h" |
32 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 32 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
33 #include "base/threading/platform_thread.h" | 33 #include "base/threading/platform_thread.h" |
34 #include "base/threading/thread_restrictions.h" | 34 #include "base/threading/thread_restrictions.h" |
35 | 35 |
36 #ifdef USE_ALLOCATED_TYPE | |
37 #include "base/allocator/allocated_type_tcmalloc.h" | |
38 #endif | |
39 | |
36 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
37 #include <sys/ioctl.h> | 41 #include <sys/ioctl.h> |
38 #endif | 42 #endif |
39 | 43 |
40 #if defined(OS_FREEBSD) | 44 #if defined(OS_FREEBSD) |
41 #include <sys/event.h> | 45 #include <sys/event.h> |
42 #include <sys/ucontext.h> | 46 #include <sys/ucontext.h> |
43 #endif | 47 #endif |
44 | 48 |
45 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
632 | 636 |
633 if (options.new_process_group) { | 637 if (options.new_process_group) { |
634 // Instead of inheriting the process group ID of the parent, the child | 638 // Instead of inheriting the process group ID of the parent, the child |
635 // starts off a new process group with pgid equal to its process ID. | 639 // starts off a new process group with pgid equal to its process ID. |
636 if (setpgid(0, 0) < 0) { | 640 if (setpgid(0, 0) < 0) { |
637 RAW_LOG(ERROR, "setpgid failed"); | 641 RAW_LOG(ERROR, "setpgid failed"); |
638 _exit(127); | 642 _exit(127); |
639 } | 643 } |
640 } | 644 } |
641 | 645 |
646 #ifdef USE_ALLOCATED_TYPE | |
647 // Stop interceptors for allocated type to avoid using locks. | |
648 StopAllocatedTypeIntercept(); | |
649 #endif | |
Dai Mikurube (NOT FULLTIME)
2012/08/07 11:35:55
Note: I kept #ifdef here since the file has just t
jar (doing other things)
2012/08/07 17:07:34
Readers can't skip the ifdef without trying to fig
Dai Mikurube (NOT FULLTIME)
2012/08/08 06:16:23
Ok, done in base/allocator/allocated_type_tcmalloc
| |
642 if (options.maximize_rlimits) { | 650 if (options.maximize_rlimits) { |
643 // Some resource limits need to be maximal in this child. | 651 // Some resource limits need to be maximal in this child. |
644 std::set<int>::const_iterator resource; | 652 std::set<int>::const_iterator resource; |
645 for (resource = options.maximize_rlimits->begin(); | 653 for (resource = options.maximize_rlimits->begin(); |
646 resource != options.maximize_rlimits->end(); | 654 resource != options.maximize_rlimits->end(); |
647 ++resource) { | 655 ++resource) { |
648 struct rlimit limit; | 656 struct rlimit limit; |
649 if (getrlimit(*resource, &limit) < 0) { | 657 if (getrlimit(*resource, &limit) < 0) { |
650 RAW_LOG(WARNING, "getrlimit failed"); | 658 RAW_LOG(WARNING, "getrlimit failed"); |
651 } else if (limit.rlim_cur < limit.rlim_max) { | 659 } else if (limit.rlim_cur < limit.rlim_max) { |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1100 | 1108 |
1101 // Obscure fork() rule: in the child, if you don't end up doing exec*(), | 1109 // Obscure fork() rule: in the child, if you don't end up doing exec*(), |
1102 // you call _exit() instead of exit(). This is because _exit() does not | 1110 // you call _exit() instead of exit(). This is because _exit() does not |
1103 // call any previously-registered (in the parent) exit handlers, which | 1111 // call any previously-registered (in the parent) exit handlers, which |
1104 // might do things like block waiting for threads that don't even exist | 1112 // might do things like block waiting for threads that don't even exist |
1105 // in the child. | 1113 // in the child. |
1106 int dev_null = open("/dev/null", O_WRONLY); | 1114 int dev_null = open("/dev/null", O_WRONLY); |
1107 if (dev_null < 0) | 1115 if (dev_null < 0) |
1108 _exit(127); | 1116 _exit(127); |
1109 | 1117 |
1118 #ifdef USE_ALLOCATED_TYPE | |
1119 // Stop interceptors for allocated type to avoid using locks. | |
1120 StopAllocatedTypeIntercept(); | |
1121 #endif | |
1110 fd_shuffle1.push_back(InjectionArc(pipe_fd[1], STDOUT_FILENO, true)); | 1122 fd_shuffle1.push_back(InjectionArc(pipe_fd[1], STDOUT_FILENO, true)); |
1111 fd_shuffle1.push_back(InjectionArc(dev_null, STDERR_FILENO, true)); | 1123 fd_shuffle1.push_back(InjectionArc(dev_null, STDERR_FILENO, true)); |
1112 fd_shuffle1.push_back(InjectionArc(dev_null, STDIN_FILENO, true)); | 1124 fd_shuffle1.push_back(InjectionArc(dev_null, STDIN_FILENO, true)); |
1113 // Adding another element here? Remeber to increase the argument to | 1125 // Adding another element here? Remeber to increase the argument to |
1114 // reserve(), above. | 1126 // reserve(), above. |
1115 | 1127 |
1116 std::copy(fd_shuffle1.begin(), fd_shuffle1.end(), | 1128 std::copy(fd_shuffle1.begin(), fd_shuffle1.end(), |
1117 std::back_inserter(fd_shuffle2)); | 1129 std::back_inserter(fd_shuffle2)); |
1118 | 1130 |
1119 if (!ShuffleFileDescriptors(&fd_shuffle1)) | 1131 if (!ShuffleFileDescriptors(&fd_shuffle1)) |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1327 if (IsChildDead(process)) | 1339 if (IsChildDead(process)) |
1328 return; | 1340 return; |
1329 | 1341 |
1330 BackgroundReaper* reaper = new BackgroundReaper(process, 0); | 1342 BackgroundReaper* reaper = new BackgroundReaper(process, 0); |
1331 PlatformThread::CreateNonJoinable(0, reaper); | 1343 PlatformThread::CreateNonJoinable(0, reaper); |
1332 } | 1344 } |
1333 | 1345 |
1334 #endif // !defined(OS_MACOSX) | 1346 #endif // !defined(OS_MACOSX) |
1335 | 1347 |
1336 } // namespace base | 1348 } // namespace base |
OLD | NEW |