From 2fca9cd0da5c87806c959ba2b1241827cf0bd2b8 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 4 May 2023 22:29:31 -0500 Subject: [PATCH] Fix launching apps with a log file specified --- src/platform/windows/misc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/platform/windows/misc.cpp b/src/platform/windows/misc.cpp index be2e9e44..0b59d343 100644 --- a/src/platform/windows/misc.cpp +++ b/src/platform/windows/misc.cpp @@ -547,11 +547,14 @@ namespace platf { // Allow the log file handle to be inherited by the child process (without inheriting all of // our inheritable handles, such as our own log file handle created by SunshineSvc). + // + // Note: The value we point to here must be valid for the lifetime of the attribute list, + // so we need to point into the STARTUPINFO instead of our log_file_variable on the stack. UpdateProcThreadAttribute(startup_info.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST, - &log_file_handle, - sizeof(log_file_handle), + &startup_info.StartupInfo.hStdOutput, + sizeof(startup_info.StartupInfo.hStdOutput), NULL, NULL); }