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

Unified Diff: util/test/posix/close_multiple.cc

Issue 531203002: Add the MultiprocessExec test and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Fix indentation Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/test/posix/close_multiple.h ('k') | util/util.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/test/posix/close_multiple.cc
diff --git a/util/test/posix/close_multiple.cc b/util/test/posix/close_multiple.cc
index 0155530205f2113c23789a07160c21df31d0800e..9c70e1839361d54a5d6ba22043c7b7732ed71f55 100644
--- a/util/test/posix/close_multiple.cc
+++ b/util/test/posix/close_multiple.cc
@@ -77,7 +77,7 @@ typedef scoped_ptr<DIR, ScopedDIRCloser> ScopedDIR;
// system-specific FD directory to determine which file descriptors are open.
// This is an advantage over looping over all possible file descriptors, because
// no attempt needs to be made to close file descriptors that are not open.
-bool CloseMultipleNowOrOnExecUsingFDDir(int fd) {
+bool CloseMultipleNowOrOnExecUsingFDDir(int fd, int preserve_fd) {
#if defined(OS_MACOSX)
const char kFDDir[] = "/dev/fd";
#elif defined(OS_LINUX)
@@ -120,7 +120,7 @@ bool CloseMultipleNowOrOnExecUsingFDDir(int fd) {
return false;
}
- if (entry_fd >= fd && entry_fd != dir_fd) {
+ if (entry_fd >= fd && entry_fd != preserve_fd && entry_fd != dir_fd) {
CloseNowOrOnExec(entry_fd, false);
}
}
@@ -130,9 +130,9 @@ bool CloseMultipleNowOrOnExecUsingFDDir(int fd) {
} // namespace
-void CloseMultipleNowOrOnExec(int fd) {
- if (CloseMultipleNowOrOnExecUsingFDDir(fd)) {
- return;
+void CloseMultipleNowOrOnExec(int fd, int preserve_fd) {
+ if (CloseMultipleNowOrOnExecUsingFDDir(fd, preserve_fd)) {
+ return;
}
// Fallback: close every file descriptor starting at |fd| and ending at the
@@ -147,7 +147,9 @@ void CloseMultipleNowOrOnExec(int fd) {
max_fd = std::max(max_fd, getdtablesize());
for (int entry_fd = fd; entry_fd < max_fd; ++entry_fd) {
- CloseNowOrOnExec(entry_fd, true);
+ if (entry_fd != preserve_fd) {
+ CloseNowOrOnExec(entry_fd, true);
+ }
}
}
« no previous file with comments | « util/test/posix/close_multiple.h ('k') | util/util.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698