mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1330496 - Part 1: Remove MOZ_WIN_INHERIT_STD_HANDLES_PRE_VISTA support for inheriting stdout/stderr handles on XP. r=bobowen
MozReview-Commit-ID: B7qJdK2sjv5 --HG-- extra : rebase_source : 4053054009359c0a775dae5ad5e24ba74b4c7c7b extra : amend_source : 3231886a86fd03ac52f3717e22f33a7b4dc41f54 extra : histedit_source : 4533b894f9894bf5c883943bc53b260faa2ae8b1
This commit is contained in:
parent
66779abf27
commit
4d95c4db20
@ -19,9 +19,6 @@
|
||||
#include "base/win_util.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "prenv.h"
|
||||
|
||||
#include "mozilla/WindowsVersion.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -280,13 +277,11 @@ bool LaunchApp(const std::wstring& cmdline,
|
||||
// We want to inherit the std handles so dump() statements and assertion
|
||||
// messages in the child process can be seen - but we *do not* want to
|
||||
// blindly have all handles inherited. Vista and later has a technique
|
||||
// where only specified handles are inherited - so we use this technique if
|
||||
// we can. If that technique isn't available (or it fails), we just don't
|
||||
// inherit anything. This can cause us a problem for Windows XP testing,
|
||||
// because we sometimes need the handles to get inherited for test logging to
|
||||
// work. So we also inherit when a specific environment variable is set.
|
||||
// where only specified handles are inherited - so we use this technique.
|
||||
// If that fails we just don't inherit anything.
|
||||
DWORD dwCreationFlags = 0;
|
||||
BOOL bInheritHandles = FALSE;
|
||||
|
||||
// We use a STARTUPINFOEX, but if we can't do the thread attribute thing, we
|
||||
// just pass the size of a STARTUPINFO.
|
||||
STARTUPINFOEX startup_info_ex;
|
||||
@ -302,40 +297,29 @@ bool LaunchApp(const std::wstring& cmdline,
|
||||
HANDLE handlesToInherit[2];
|
||||
int handleCount = 0;
|
||||
|
||||
// Don't even bother trying pre-Vista...
|
||||
if (mozilla::IsVistaOrLater()) {
|
||||
// setup our handle array first - if we end up with no handles that can
|
||||
// be inherited we can avoid trying to do the ThreadAttributeList dance...
|
||||
HANDLE stdOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
HANDLE stdErr = ::GetStdHandle(STD_ERROR_HANDLE);
|
||||
// setup our handle array first - if we end up with no handles that can
|
||||
// be inherited we can avoid trying to do the ThreadAttributeList dance...
|
||||
HANDLE stdOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
HANDLE stdErr = ::GetStdHandle(STD_ERROR_HANDLE);
|
||||
|
||||
if (IsInheritableHandle(stdOut))
|
||||
handlesToInherit[handleCount++] = stdOut;
|
||||
if (stdErr != stdOut && IsInheritableHandle(stdErr))
|
||||
handlesToInherit[handleCount++] = stdErr;
|
||||
if (IsInheritableHandle(stdOut))
|
||||
handlesToInherit[handleCount++] = stdOut;
|
||||
if (stdErr != stdOut && IsInheritableHandle(stdErr))
|
||||
handlesToInherit[handleCount++] = stdErr;
|
||||
|
||||
if (handleCount) {
|
||||
lpAttributeList = CreateThreadAttributeList(handlesToInherit, handleCount);
|
||||
if (lpAttributeList) {
|
||||
// it's safe to inherit handles, so arrange for that...
|
||||
startup_info.cb = sizeof(startup_info_ex);
|
||||
startup_info.dwFlags |= STARTF_USESTDHANDLES;
|
||||
startup_info.hStdOutput = stdOut;
|
||||
startup_info.hStdError = stdErr;
|
||||
startup_info.hStdInput = INVALID_HANDLE_VALUE;
|
||||
startup_info_ex.lpAttributeList = lpAttributeList;
|
||||
dwCreationFlags |= EXTENDED_STARTUPINFO_PRESENT;
|
||||
bInheritHandles = TRUE;
|
||||
}
|
||||
if (handleCount) {
|
||||
lpAttributeList = CreateThreadAttributeList(handlesToInherit, handleCount);
|
||||
if (lpAttributeList) {
|
||||
// it's safe to inherit handles, so arrange for that...
|
||||
startup_info.cb = sizeof(startup_info_ex);
|
||||
startup_info.dwFlags |= STARTF_USESTDHANDLES;
|
||||
startup_info.hStdOutput = stdOut;
|
||||
startup_info.hStdError = stdErr;
|
||||
startup_info.hStdInput = INVALID_HANDLE_VALUE;
|
||||
startup_info_ex.lpAttributeList = lpAttributeList;
|
||||
dwCreationFlags |= EXTENDED_STARTUPINFO_PRESENT;
|
||||
bInheritHandles = TRUE;
|
||||
}
|
||||
} else if (PR_GetEnv("MOZ_WIN_INHERIT_STD_HANDLES_PRE_VISTA")) {
|
||||
// Even if we can't limit what gets inherited, we sometimes want to inherit
|
||||
// stdout/err for testing purposes.
|
||||
startup_info.dwFlags |= STARTF_USESTDHANDLES;
|
||||
startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE);
|
||||
startup_info.hStdInput = INVALID_HANDLE_VALUE;
|
||||
bInheritHandles = TRUE;
|
||||
}
|
||||
|
||||
PROCESS_INFORMATION process_info;
|
||||
|
@ -409,14 +409,6 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path,
|
||||
// have limited which handles will be inherited.
|
||||
inherit_handles = true;
|
||||
}
|
||||
} else if (getenv("MOZ_WIN_INHERIT_STD_HANDLES_PRE_VISTA")) {
|
||||
// On pre-Vista versions even if we can't limit what gets inherited, we
|
||||
// sometimes want to inherit stdout/err for testing purposes.
|
||||
startup_info.startup_info()->dwFlags |= STARTF_USESTDHANDLES;
|
||||
startup_info.startup_info()->hStdInput = INVALID_HANDLE_VALUE;
|
||||
startup_info.startup_info()->hStdOutput = policy_base->GetStdoutHandle();
|
||||
startup_info.startup_info()->hStdError = policy_base->GetStderrHandle();
|
||||
inherit_handles = true;
|
||||
}
|
||||
|
||||
// Construct the thread pool here in case it is expensive.
|
||||
|
@ -1,7 +1,6 @@
|
||||
Please add a link to the bugzilla bug and patch name that should be re-applied.
|
||||
Also, please update any existing links to their actual mozilla-central changeset.
|
||||
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1287426 bug1287426part4.patch
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1287426 bug1287426part5.patch
|
||||
https://hg.mozilla.org/mozilla-central/rev/7df8d6639971
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1287426 bug1287426part7.patch
|
||||
|
Loading…
Reference in New Issue
Block a user