summaryrefslogtreecommitdiff
path: root/src/spawn.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-07-14 21:22:44 +0200
committerTannin <devnull@localhost>2014-07-14 21:22:44 +0200
commit84c66727bff954fd0820fc9f33833848496e9531 (patch)
treeca3497150eb9f124d7a124cc48c8d6d1330b7243 /src/spawn.cpp
parentaf8973312188c3d90b8e3f8e2f8036d35e3f21ea (diff)
- when highlighting a mod the overwritten and overwriting mods are now highlighted in the list
- when starting an external application MO now wraps the process in a job and waits on that instead. This way MO is not unlocked early when skyrim is started through skse - mod info dialog no longer offers the esp tab for foreign mods because that caused confusion - updated translation files - download directory and mod directory are now created if necessary - bugfix: staging script created unnecessary copies of translation files - bugfix: potential invalid array access when trying to determine best mod order - bugfix: deleter file wasn't removed after esp hiding was disabled - bugfix: potential access to to un-initialized login reply - bugfix: changed the initialization order to allow more ui controls to be localized
Diffstat (limited to 'src/spawn.cpp')
-rw-r--r--src/spawn.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/spawn.cpp b/src/spawn.cpp
index 6adafba0..d314a326 100644
--- a/src/spawn.cpp
+++ b/src/spawn.cpp
@@ -88,7 +88,7 @@ bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, bool sus
commandLine,
NULL, NULL, // no special process or thread attributes
inheritHandles, // inherit handles if we plan to use stdout or stderr reroute
- suspended ? CREATE_SUSPENDED : 0, // create suspended so I have time to inject the DLL
+ CREATE_BREAKAWAY_FROM_JOB | (suspended ? CREATE_SUSPENDED : 0), // create suspended so I have time to inject the DLL
NULL, // same environment as parent
currentDirectory, // current directory
&si, &pi // startup and process information
@@ -117,12 +117,18 @@ HANDLE startBinary(const QFileInfo &binary,
HANDLE stdOut,
HANDLE stdErr)
{
+ HANDLE jobObject = ::CreateJobObject(NULL, NULL);
+
+ if (jobObject == NULL) {
+ qWarning("failed to create job object: %lu", ::GetLastError());
+ }
+
HANDLE processHandle, threadHandle;
std::wstring binaryName = ToWString(QDir::toNativeSeparators(binary.absoluteFilePath()));
std::wstring currentDirectoryName = ToWString(QDir::toNativeSeparators(currentDirectory.absolutePath()));
try {
- if (!spawn(binaryName.c_str(), ToWString(arguments).c_str(), currentDirectoryName.c_str(), hooked,
+ if (!spawn(binaryName.c_str(), ToWString(arguments).c_str(), currentDirectoryName.c_str(), true,
stdOut, stdErr, processHandle, threadHandle)) {
reportError(QObject::tr("failed to spawn \"%1\"").arg(binary.fileName()));
return INVALID_HANDLE_VALUE;
@@ -170,12 +176,22 @@ HANDLE startBinary(const QFileInfo &binary,
#ifdef _DEBUG
reportError("ready?");
#endif // DEBUG
- if (::ResumeThread(threadHandle) == (DWORD)-1) {
- reportError(QObject::tr("failed to run \"%1\"").arg(binary.fileName()));
- return INVALID_HANDLE_VALUE;
- }
}
- return processHandle;
+
+ if (::AssignProcessToJobObject(jobObject, processHandle) == 0) {
+ qWarning("failed to assign to job object: %lu", ::GetLastError());
+ ::CloseHandle(jobObject);
+ jobObject = processHandle;
+ } else {
+ ::CloseHandle(processHandle);
+ }
+
+ if (::ResumeThread(threadHandle) == (DWORD)-1) {
+ reportError(QObject::tr("failed to run \"%1\"").arg(binary.fileName()));
+ return INVALID_HANDLE_VALUE;
+ }
+ ::CloseHandle(threadHandle);
+ return jobObject;
}
/*