MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / DeparentSelf

Function DeparentSelf

Source/Tools/FEXServer/Main.cpp:107–121  ·  view source on GitHub ↗

* @brief Deparents itself by forking and terminating the parent process. */

Source from the content-addressed store, hash-verified

105 * @brief Deparents itself by forking and terminating the parent process.
106 */
107void DeparentSelf() {
108 auto SystemdEnv = getenv("INVOCATION_ID");
109 if (SystemdEnv) {
110 // If FEXServer was launched through systemd then don't deparent, otherwise systemd kills the entire server.
111 return;
112 }
113
114 pid_t pid = fork();
115
116 if (pid != 0) {
117 // Parent is leaving to force this process to deparent itself
118 // This lets this process become the child of whatever the reaper parent is
119 _exit(0);
120 }
121}
122} // namespace
123
124int main(int argc, char** argv, char** const envp) {

Callers 1

mainFunction · 0.85

Calls 1

getenvFunction · 0.85

Tested by

no test coverage detected