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

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: " 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
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..ae4b900842b4dca18972dc62b443ba9cf7c9ec1d 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,8 +130,8 @@ bool CloseMultipleNowOrOnExecUsingFDDir(int fd) {
} // namespace
-void CloseMultipleNowOrOnExec(int fd) {
- if (CloseMultipleNowOrOnExecUsingFDDir(fd)) {
+void CloseMultipleNowOrOnExec(int fd, int preserve_fd) {
+ if (CloseMultipleNowOrOnExecUsingFDDir(fd, preserve_fd)) {
return;
Robert Sesek 2014/09/03 20:56:24 nit: indention
}
@@ -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);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698