Index: client/crashpad_client_win.cc |
diff --git a/client/crashpad_client_win.cc b/client/crashpad_client_win.cc |
index 40a856f33f03ba03cbeb2c57c0e6ae59a30b91f0..8b0a6039d64fd13c3f1783d072ce32ac2be3d3dd 100644 |
--- a/client/crashpad_client_win.cc |
+++ b/client/crashpad_client_win.cc |
@@ -128,9 +128,16 @@ struct ScopedProcThreadAttributeListTraits { |
} |
}; |
-using ScopedProcThreadAttributeList = |
- base::ScopedGeneric<PPROC_THREAD_ATTRIBUTE_LIST, |
- ScopedProcThreadAttributeListTraits>; |
+bool IsInheritableHandle(HANDLE handle) { |
+ if (!handle || handle == INVALID_HANDLE_VALUE) |
+ return false; |
+ // File handles (FILE_TYPE_DISK) and pipe handles (FILE_TYPE_PIPE) are known |
Mark Mentovai
2015/11/25 00:33:16
Blank line before.
scottmg
2015/11/25 00:36:13
Done.
|
+ // to be inheritable. Console handles (FILE_TYPE_CHAR) are not inheritable via |
+ // PROC_THREAD_ATTRIBUTE_HANDLE_LIST. See |
+ // https://bugs.chromium.org/p/crashpad/issues/detail?id=77. |
Mark Mentovai
2015/11/25 00:33:16
https://crashpad.chromium.org/bug/77
scottmg
2015/11/25 00:36:13
Done. (Doesn't quite fit with trailing '.' still.)
|
+ DWORD handle_type = GetFileType(handle); |
+ return handle_type == FILE_TYPE_DISK || handle_type == FILE_TYPE_PIPE; |
+} |
// Adds |handle| to |handle_list| if it appears valid, and is not already in |
// |handle_list|. |
@@ -142,17 +149,22 @@ using ScopedProcThreadAttributeList = |
// silently not inherit any handles. |
// |
// Use this function to add handles with uncertain validities. |
-void AddHandleToListIfValid(std::vector<HANDLE>* handle_list, HANDLE handle) { |
+void AddHandleToListIfValidAndInheritable(std::vector<HANDLE>* handle_list, |
+ HANDLE handle) { |
// There doesn't seem to be any documentation of this, but if there's a handle |
// duplicated in this list, CreateProcess() fails with |
// ERROR_INVALID_PARAMETER. |
- if (handle && handle != INVALID_HANDLE_VALUE && |
+ if (IsInheritableHandle(handle) && |
std::find(handle_list->begin(), handle_list->end(), handle) == |
handle_list->end()) { |
handle_list->push_back(handle); |
} |
} |
+using ScopedProcThreadAttributeList = |
Mark Mentovai
2015/11/25 00:33:16
Can you keep this with the traits it belongs with?
scottmg
2015/11/25 00:36:13
Oops, I'll put it back.
|
+ base::ScopedGeneric<PPROC_THREAD_ATTRIBUTE_LIST, |
+ ScopedProcThreadAttributeListTraits>; |
+ |
} // namespace |
namespace crashpad { |
@@ -267,9 +279,12 @@ bool CrashpadClient::StartHandler( |
handle_list.reserve(4); |
handle_list.push_back(pipe_write); |
- AddHandleToListIfValid(&handle_list, startup_info.StartupInfo.hStdInput); |
- AddHandleToListIfValid(&handle_list, startup_info.StartupInfo.hStdOutput); |
- AddHandleToListIfValid(&handle_list, startup_info.StartupInfo.hStdError); |
+ AddHandleToListIfValidAndInheritable(&handle_list, |
+ startup_info.StartupInfo.hStdInput); |
+ AddHandleToListIfValidAndInheritable(&handle_list, |
+ startup_info.StartupInfo.hStdOutput); |
+ AddHandleToListIfValidAndInheritable(&handle_list, |
+ startup_info.StartupInfo.hStdError); |
rv = update_proc_thread_attribute( |
startup_info.lpAttributeList, |
0, |