mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1037445: When pre-Vista, for testing purposes allow std handles to be inherited by child process when an env var is set. r=jmaher,dvander
This commit is contained in:
parent
e9f6582fa6
commit
7487f3d78b
@ -17,6 +17,7 @@
|
||||
#include "base/win_util.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "prenv.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -275,10 +276,9 @@ bool LaunchApp(const std::wstring& cmdline,
|
||||
// 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 means that dump() etc isn't going to be seen on
|
||||
// XP release builds, but that's OK (developers who really care can run a
|
||||
// debug build on XP, where the processes are marked as "console" apps, so
|
||||
// things work without these hoops)
|
||||
// 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.
|
||||
DWORD dwCreationFlags = 0;
|
||||
BOOL bInheritHandles = FALSE;
|
||||
// We use a STARTUPINFOEX, but if we can't do the thread attribute thing, we
|
||||
@ -305,21 +305,30 @@ bool LaunchApp(const std::wstring& cmdline,
|
||||
if (stdErr != stdOut && IsInheritableHandle(stdErr))
|
||||
handlesToInherit[handleCount++] = stdErr;
|
||||
|
||||
if (handleCount)
|
||||
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);
|
||||
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;
|
||||
startup_info_ex.lpAttributeList = lpAttributeList;
|
||||
dwCreationFlags |= EXTENDED_STARTUPINFO_PRESENT;
|
||||
bInheritHandles = TRUE;
|
||||
}
|
||||
|
||||
PROCESS_INFORMATION process_info;
|
||||
BOOL createdOK = CreateProcess(NULL,
|
||||
const_cast<wchar_t*>(cmdline.c_str()), NULL, NULL,
|
||||
|
@ -1238,6 +1238,14 @@ class Mochitest(MochitestUtilsMixin):
|
||||
# via the commandline at your own risk.
|
||||
browserEnv["XPCOM_DEBUG_BREAK"] = "stack"
|
||||
|
||||
# When creating child processes on Windows pre-Vista (e.g. Windows XP) we
|
||||
# don't normally inherit stdout/err handles, because you can only do it by
|
||||
# inheriting all other inheritable handles as well.
|
||||
# We need to inherit them for plain mochitests for test logging purposes, so
|
||||
# we do so on the basis of a specific environment variable.
|
||||
if self.getTestFlavor(options) == "mochitest":
|
||||
browserEnv["MOZ_WIN_INHERIT_STD_HANDLES_PRE_VISTA"] = "1"
|
||||
|
||||
# interpolate environment passed with options
|
||||
try:
|
||||
browserEnv.update(dict(parseKeyValue(options.environment, context='--setenv')))
|
||||
|
Loading…
Reference in New Issue
Block a user