OLD | NEW |
1 // Copyright (c) 2011 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> |
11 #include <sys/time.h> | 11 #include <sys/time.h> |
(...skipping 13 matching lines...) Expand all Loading... |
25 #include "base/file_util.h" | 25 #include "base/file_util.h" |
26 #include "base/logging.h" | 26 #include "base/logging.h" |
27 #include "base/memory/scoped_ptr.h" | 27 #include "base/memory/scoped_ptr.h" |
28 #include "base/process_util.h" | 28 #include "base/process_util.h" |
29 #include "base/stringprintf.h" | 29 #include "base/stringprintf.h" |
30 #include "base/synchronization/waitable_event.h" | 30 #include "base/synchronization/waitable_event.h" |
31 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 31 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
32 #include "base/threading/platform_thread.h" | 32 #include "base/threading/platform_thread.h" |
33 #include "base/threading/thread_restrictions.h" | 33 #include "base/threading/thread_restrictions.h" |
34 | 34 |
| 35 #if defined(OS_CHROMEOS) |
| 36 #include <sys/ioctl.h> |
| 37 #endif |
| 38 |
35 #if defined(OS_FREEBSD) | 39 #if defined(OS_FREEBSD) |
36 #include <sys/event.h> | 40 #include <sys/event.h> |
37 #include <sys/ucontext.h> | 41 #include <sys/ucontext.h> |
38 #endif | 42 #endif |
39 | 43 |
40 #if defined(OS_MACOSX) | 44 #if defined(OS_MACOSX) |
41 #include <crt_externs.h> | 45 #include <crt_externs.h> |
42 #include <sys/event.h> | 46 #include <sys/event.h> |
43 #else | 47 #else |
44 extern char** environ; | 48 extern char** environ; |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 // any hidden calls to malloc. | 674 // any hidden calls to malloc. |
671 void *malloc_thunk = | 675 void *malloc_thunk = |
672 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(malloc) & ~4095); | 676 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(malloc) & ~4095); |
673 mprotect(malloc_thunk, 4096, PROT_READ | PROT_WRITE | PROT_EXEC); | 677 mprotect(malloc_thunk, 4096, PROT_READ | PROT_WRITE | PROT_EXEC); |
674 memset(reinterpret_cast<void*>(malloc), 0xff, 8); | 678 memset(reinterpret_cast<void*>(malloc), 0xff, 8); |
675 #endif // 0 | 679 #endif // 0 |
676 | 680 |
677 // DANGER: no calls to malloc are allowed from now on: | 681 // DANGER: no calls to malloc are allowed from now on: |
678 // http://crbug.com/36678 | 682 // http://crbug.com/36678 |
679 | 683 |
| 684 #if defined(OS_CHROMEOS) |
| 685 if (options.ctrl_terminal_fd >= 0) { |
| 686 // Set process' controlling terminal. |
| 687 if (HANDLE_EINTR(setsid()) != -1) { |
| 688 if (HANDLE_EINTR( |
| 689 ioctl(options.ctrl_terminal_fd, TIOCSCTTY, NULL)) == -1) { |
| 690 RAW_LOG(WARNING, "ioctl(TIOCSCTTY), ctrl terminal not set"); |
| 691 } |
| 692 } else { |
| 693 RAW_LOG(WARNING, "setsid failed, ctrl terminal not set"); |
| 694 } |
| 695 } |
| 696 #endif // defined(OS_CHROMEOS) |
| 697 |
680 if (options.fds_to_remap) { | 698 if (options.fds_to_remap) { |
681 for (file_handle_mapping_vector::const_iterator | 699 for (file_handle_mapping_vector::const_iterator |
682 it = options.fds_to_remap->begin(); | 700 it = options.fds_to_remap->begin(); |
683 it != options.fds_to_remap->end(); ++it) { | 701 it != options.fds_to_remap->end(); ++it) { |
684 fd_shuffle1.push_back(InjectionArc(it->first, it->second, false)); | 702 fd_shuffle1.push_back(InjectionArc(it->first, it->second, false)); |
685 fd_shuffle2.push_back(InjectionArc(it->first, it->second, false)); | 703 fd_shuffle2.push_back(InjectionArc(it->first, it->second, false)); |
686 } | 704 } |
687 } | 705 } |
688 | 706 |
689 #if defined(OS_MACOSX) | 707 #if defined(OS_MACOSX) |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 if (IsChildDead(process)) | 1323 if (IsChildDead(process)) |
1306 return; | 1324 return; |
1307 | 1325 |
1308 BackgroundReaper* reaper = new BackgroundReaper(process, 0); | 1326 BackgroundReaper* reaper = new BackgroundReaper(process, 0); |
1309 PlatformThread::CreateNonJoinable(0, reaper); | 1327 PlatformThread::CreateNonJoinable(0, reaper); |
1310 } | 1328 } |
1311 | 1329 |
1312 #endif // !defined(OS_MACOSX) | 1330 #endif // !defined(OS_MACOSX) |
1313 | 1331 |
1314 } // namespace base | 1332 } // namespace base |
OLD | NEW |