fix(session): monitor Windows lifetime without repeated Wine startups
Keep process observations in the resident session marker and bound utility pipe reads. Reap managed-prefix Wine workers through pidfds, including WebView2 thread groups whose leaders already exited.
This commit is contained in:
1 parent
e7724c6d86
commit
f02dcdd8c0
2 files changed
+283
-83
No files matched your search
+42
-3
@@ -4,10 +4,34 @@
|
||||
* GameViewerService enumerates processes for a winlogon session token
|
||||
* source before it initialises; under plain Wine none exists and the
|
||||
* service never leaves its initial state (the launcher waits at the
|
||||
* splash forever). This process only needs to exist with that name.
|
||||
* splash forever). It also reports the client's Windows process presence
|
||||
* over its inherited pipe, avoiding a new Wine/tasklist process per poll.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <tlhelp32.h>
|
||||
|
||||
static char client_present(const WCHAR *image)
|
||||
{
|
||||
PROCESSENTRY32W entry = {0};
|
||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if (snapshot == INVALID_HANDLE_VALUE)
|
||||
return '?';
|
||||
entry.dwSize = sizeof(entry);
|
||||
if (!Process32FirstW(snapshot, &entry)) {
|
||||
CloseHandle(snapshot);
|
||||
return '?';
|
||||
}
|
||||
do {
|
||||
if (!lstrcmpiW(entry.szExeFile, image)) {
|
||||
CloseHandle(snapshot);
|
||||
return '1';
|
||||
}
|
||||
} while (Process32NextW(snapshot, &entry));
|
||||
DWORD error = GetLastError();
|
||||
CloseHandle(snapshot);
|
||||
return error == ERROR_NO_MORE_FILES ? '0' : '?';
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR command_line,
|
||||
int show_command)
|
||||
@@ -16,6 +40,21 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR command_line,
|
||||
(void)previous;
|
||||
(void)command_line;
|
||||
(void)show_command;
|
||||
Sleep(INFINITE);
|
||||
return 0;
|
||||
WCHAR image[MAX_PATH];
|
||||
DWORD length = GetEnvironmentVariableW(L"UUR_MONITOR_CLIENT", image,
|
||||
MAX_PATH);
|
||||
if (!length) {
|
||||
Sleep(INFINITE);
|
||||
return 0;
|
||||
}
|
||||
if (length >= MAX_PATH)
|
||||
return 1;
|
||||
HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
for (;;) {
|
||||
char state = client_present(image);
|
||||
DWORD written;
|
||||
if (!WriteFile(output, &state, 1, &written, NULL) || written != 1)
|
||||
return 1;
|
||||
Sleep(500);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user