MCPcopy Create free account
hub / github.com/ClassicOldSong/Apollo / CreateJobObjectForChildProcess

Function CreateJobObjectForChildProcess

tools/sunshinesvc.cpp:54–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54HANDLE CreateJobObjectForChildProcess() {
55 HANDLE job_handle = CreateJobObjectW(nullptr, nullptr);
56 if (!job_handle) {
57 return nullptr;
58 }
59
60 JOBOBJECT_EXTENDED_LIMIT_INFORMATION job_limit_info = {};
61
62 // Kill Sunshine.exe when the final job object handle is closed (which will happen if we terminate unexpectedly).
63 // This ensures we don't leave an orphaned Sunshine.exe running with an inherited handle to our log file.
64 job_limit_info.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
65
66 // Allow Sunshine.exe to use CREATE_BREAKAWAY_FROM_JOB when spawning processes to ensure they can to live beyond
67 // the lifetime of SunshineSvc.exe. This avoids unexpected user data loss if we crash or are killed.
68 job_limit_info.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_BREAKAWAY_OK;
69
70 if (!SetInformationJobObject(job_handle, JobObjectExtendedLimitInformation, &job_limit_info, sizeof(job_limit_info))) {
71 CloseHandle(job_handle);
72 return nullptr;
73 }
74
75 return job_handle;
76}
77
78LPPROC_THREAD_ATTRIBUTE_LIST AllocateProcThreadAttributeList(DWORD attribute_count) {
79 SIZE_T size;

Callers 1

ServiceMainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected