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

Side by Side Diff: base/test/multiprocess_test_android.cc

Issue 349323003: [Android]: Replace calls to getdtablesize with sysconf(_SC_OPEN_MAX) in tools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « no previous file | tools/android/adb_reboot/adb_reboot.c » ('j') | 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 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 "base/posix/global_descriptors.h" 5 #include "base/posix/global_descriptors.h"
6 #include "base/test/multiprocess_test.h" 6 #include "base/test/multiprocess_test.h"
7 7
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 // Child process. 40 // Child process.
41 std::hash_set<int> fds_to_keep_open; 41 std::hash_set<int> fds_to_keep_open;
42 for (FileHandleMappingVector::const_iterator it = fds_to_remap->begin(); 42 for (FileHandleMappingVector::const_iterator it = fds_to_remap->begin();
43 it != fds_to_remap->end(); ++it) { 43 it != fds_to_remap->end(); ++it) {
44 fds_to_keep_open.insert(it->first); 44 fds_to_keep_open.insert(it->first);
45 } 45 }
46 // Keep standard FDs (stdin, stdout, stderr, etc.) open since this 46 // Keep standard FDs (stdin, stdout, stderr, etc.) open since this
47 // is not meant to spawn a daemon. 47 // is not meant to spawn a daemon.
48 int base = GlobalDescriptors::kBaseDescriptor; 48 int base = GlobalDescriptors::kBaseDescriptor;
49 for (int fd = base; fd < getdtablesize(); ++fd) { 49 for (int fd = base; fd < sysconf(_SC_OPEN_MAX); ++fd) {
50 if (fds_to_keep_open.find(fd) == fds_to_keep_open.end()) { 50 if (fds_to_keep_open.find(fd) == fds_to_keep_open.end()) {
51 close(fd); 51 close(fd);
52 } 52 }
53 } 53 }
54 for (FileHandleMappingVector::const_iterator it = fds_to_remap->begin(); 54 for (FileHandleMappingVector::const_iterator it = fds_to_remap->begin();
55 it != fds_to_remap->end(); ++it) { 55 it != fds_to_remap->end(); ++it) {
56 int old_fd = it->first; 56 int old_fd = it->first;
57 int new_fd = it->second; 57 int new_fd = it->second;
58 if (dup2(old_fd, new_fd) < 0) { 58 if (dup2(old_fd, new_fd) < 0) {
59 PLOG(FATAL) << "dup2"; 59 PLOG(FATAL) << "dup2";
60 } 60 }
61 close(old_fd); 61 close(old_fd);
62 } 62 }
63 _exit(multi_process_function_list::InvokeChildProcessTest(procname)); 63 _exit(multi_process_function_list::InvokeChildProcessTest(procname));
64 return 0; 64 return 0;
65 } 65 }
66 66
67 } // namespace base 67 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | tools/android/adb_reboot/adb_reboot.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698