| 88 | |
| 89 | |
| 90 | Subprocess::ChildHook Subprocess::ChildHook::SETSID() |
| 91 | { |
| 92 | return Subprocess::ChildHook([]() -> Try<Nothing> { |
| 93 | // TODO(josephw): By default, child processes on Windows do not |
| 94 | // terminate when the parent terminates. We need to implement |
| 95 | // `JobObject` support to change this default. |
| 96 | #ifndef __WINDOWS__ |
| 97 | // Put child into its own process session to prevent the parent |
| 98 | // suicide on child process SIGKILL/SIGTERM. |
| 99 | if (::setsid() == -1) { |
| 100 | return Error("Could not setsid"); |
| 101 | } |
| 102 | #endif // __WINDOWS__ |
| 103 | |
| 104 | return Nothing(); |
| 105 | }); |
| 106 | } |
| 107 | |
| 108 | |
| 109 | #ifndef __WINDOWS__ |