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

Side by Side Diff: base/process_util_unittest.cc

Issue 293018: Fix ProcessUtilTest.FDRemapping hang on x86_64 by counting open fds in child ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 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 | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #define _CRT_SECURE_NO_WARNINGS 5 #define _CRT_SECURE_NO_WARNINGS
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/eintr_wrapper.h" 8 #include "base/eintr_wrapper.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/multiprocess_test.h" 10 #include "base/multiprocess_test.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 const int kChildPipe = 20; // FD # for write end of pipe in child process. 192 const int kChildPipe = 20; // FD # for write end of pipe in child process.
193 MULTIPROCESS_TEST_MAIN(ProcessUtilsLeakFDChildProcess) { 193 MULTIPROCESS_TEST_MAIN(ProcessUtilsLeakFDChildProcess) {
194 // This child process counts the number of open FDs, it then writes that 194 // This child process counts the number of open FDs, it then writes that
195 // number out to a pipe connected to the parent. 195 // number out to a pipe connected to the parent.
196 int num_open_files = 0; 196 int num_open_files = 0;
197 int write_pipe = kChildPipe; 197 int write_pipe = kChildPipe;
198 int max_files = GetMaxFilesOpenInProcess(); 198 int max_files = GetMaxFilesOpenInProcess();
199 for (int i = STDERR_FILENO + 1; i < max_files; i++) { 199 for (int i = STDERR_FILENO + 1; i < max_files; i++) {
200 if (i != kChildPipe) { 200 if (i != kChildPipe) {
201 if (HANDLE_EINTR(close(i)) != -1) { 201 int fd;
202 if ((fd = HANDLE_EINTR(dup(i))) != -1) {
203 close(fd);
202 num_open_files += 1; 204 num_open_files += 1;
203 } 205 }
204 } 206 }
205 } 207 }
206 208
207 int written = HANDLE_EINTR(write(write_pipe, &num_open_files, 209 int written = HANDLE_EINTR(write(write_pipe, &num_open_files,
208 sizeof(num_open_files))); 210 sizeof(num_open_files)));
209 DCHECK_EQ(static_cast<size_t>(written), sizeof(num_open_files)); 211 DCHECK_EQ(static_cast<size_t>(written), sizeof(num_open_files));
210 HANDLE_EINTR(close(write_pipe)); 212 HANDLE_EINTR(close(write_pipe));
211 213
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 "16 0 1 0 1676099790 2957312 114 4294967295 134512640 134528148 " 296 "16 0 1 0 1676099790 2957312 114 4294967295 134512640 134528148 "
295 "3221224832 3221224344 3086339742 0 0 0 0 0 0 0 17 0 0 0"; 297 "3221224832 3221224344 3086339742 0 0 0 0 0 0 0 17 0 0 0";
296 298
297 EXPECT_EQ(0, ParseProcStatCPU(kSelfStat)); 299 EXPECT_EQ(0, ParseProcStatCPU(kSelfStat));
298 } 300 }
299 #endif 301 #endif
300 302
301 #endif // defined(OS_POSIX) 303 #endif // defined(OS_POSIX)
302 304
303 } // namespace base 305 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698