Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/creator/blender_launcher_win32.c')
-rw-r--r--source/creator/blender_launcher_win32.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/source/creator/blender_launcher_win32.c b/source/creator/blender_launcher_win32.c
index 86b0f4f3b97..f19438ad907 100644
--- a/source/creator/blender_launcher_win32.c
+++ b/source/creator/blender_launcher_win32.c
@@ -79,7 +79,26 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
BOOL success = CreateProcess(
path, buffer, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &siStartInfo, &procInfo);
+ DWORD returnValue = success ? 0 : -1;
+
if (success) {
+ /* If blender-launcher is called with background command line flag,
+ * wait for the blender process to exit and return its return value. */
+ BOOL background = FALSE;
+ int argc = 0;
+ LPWSTR *argv = CommandLineToArgvW(pCmdLine, &argc);
+ for (int i = 0; i < argc; i++) {
+ if ((wcscmp(argv[i], L"-b") == 0) || (wcscmp(argv[i], L"--background") == 0)) {
+ background = TRUE;
+ break;
+ }
+ }
+
+ if (background) {
+ WaitForSingleObject(procInfo.hProcess, INFINITE);
+ GetExitCodeProcess(procInfo.hProcess, &returnValue);
+ }
+
/* Handles in PROCESS_INFORMATION must be closed with CloseHandle when they are no longer
* needed - MSDN. Closing the handles will NOT terminate the thread/process that we just
* started. */
@@ -88,5 +107,5 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
}
free(buffer);
- return success ? 0 : -1;
+ return returnValue;
}