diff options
author | Gerald Combs <gerald@wireshark.org> | 2018-03-13 13:58:30 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2018-03-13 23:34:53 +0000 |
commit | 4c750d98a2b1274c80918a632506b462ddea31f2 (patch) | |
tree | fce0a86cba9914ffcaa82bac333c39ed90ca5dc1 | |
parent | 6dcd7a70a67a05444152bbd5691c95e5aaf8e915 (diff) |
Windows: Conditionally set CREATE_BREAKAWAY_FROM_JOB.
Set CREATE_BREAKAWAY_FROM_JOB only on Windows 7 and earlier. It's not
needed otherwise and might fail in some cases.
Change-Id: I15843b5c1ae3c352fa267228b94b6933074a07f3
Reviewed-on: https://code.wireshark.org/review/26465
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r-- | wsutil/win32-utils.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/wsutil/win32-utils.c b/wsutil/win32-utils.c index b0541a2021..6171564246 100644 --- a/wsutil/win32-utils.c +++ b/wsutil/win32-utils.c @@ -15,6 +15,7 @@ #include <log.h> #include <tchar.h> +#include <VersionHelpers.h> /* Quote the argument element if necessary, so that it will get * reconstructed correctly in the C runtime startup code. Note that @@ -193,10 +194,17 @@ BOOL win32_create_process(const char *application_name, const char *command_line gunichar2 *wcommandline = g_utf8_to_utf16(command_line, -1, NULL, NULL, NULL); // CREATE_SUSPENDED: Suspend the child so that we can cleanly call // AssignProcessToJobObject. - // CREATE_BREAKAWAY_FROM_JOB: The main application might be associated with - // a job, e.g. if we're running from ConEmu or Visual Studio. Break away - // from it so that we can cleanly call AssignProcessToJobObject on *our* job. - DWORD wcreationflags = creation_flags|CREATE_SUSPENDED|CREATE_BREAKAWAY_FROM_JOB; + DWORD wcreationflags = creation_flags|CREATE_SUSPENDED; + // CREATE_BREAKAWAY_FROM_JOB: The main application might be associated with a job, + // e.g. if we're running under "Run As", ConEmu, or Visual Studio. On Windows + // <= 7 our child process needs to break away from it so that we can cleanly + // call AssignProcessToJobObject on *our* job. + // Windows >= 8 supports nested jobs so this isn't neccessary there. + // https://blogs.msdn.microsoft.com/winsdk/2014/09/22/job-object-insanity/ + // + if (! IsWindowsVersionOrGreater(6, 2, 0)) { // Windows 8 + wcreationflags |= CREATE_BREAKAWAY_FROM_JOB; + } if (application_name) { wappname = g_utf8_to_utf16(application_name, -1, NULL, NULL, NULL); @@ -211,6 +219,7 @@ BOOL win32_create_process(const char *application_name, const char *command_line win32_kill_child_on_exit(process_information->hProcess); ResumeThread(process_information->hThread); } + // XXX Else try again if CREATE_BREAKAWAY_FROM_JOB and GetLastError() == ERROR_ACCESS_DENIED? g_free(wappname); g_free(wcommandline); |