# \[Review, 3rd\] SF-0007: Subprocess

**URL:** <https://forums.swift.org/t/review-3rd-sf-0007-subprocess/78078>\
**Category:** Foundation\
**Created:** [February 25, 2025, 1:07am UTC](https://forums.swift.org/t/review-3rd-sf-0007-subprocess/78078 "2025-02-25T01:07:00Z")\
**Posts on this page:** 1\
**Showing post:** 63

<div class="post-metadata">

**Author:** ![ahoppen](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ahoppen/32/36046_2.png) [@ahoppen](https://forums.swift.org/u/ahoppen)\
**Post date:** [March 20, 2025, 11:44pm UTC](https://forums.swift.org/t/review-3rd-sf-0007-subprocess/78078/63 "2025-03-20T23:44:34Z")

</div>

I realize that the review period is over, but I just hit a limitation of `Foundation.Process` Windows that also exists in `Subprocess` and which I’d like to share for consideration:

When launching a process that itself might launch subprocesses, it is possible to terminate the entire process tree on Posix platforms using `send(signal: .kill, toProcessGroup: true)`. However, there is no way to terminate an entire process tree on Windows. As far as I could tell, supporting this would require the process to be associated to a job object with `JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE` during process creation ([Destroying all child processes (and grandchildren) when the parent exits - The Old New Thing](https://devblogs.microsoft.com/oldnewthing/20131209-00/?p=2433)) – as a disclaimer, I have not tried had the chance to verify this approach myself.

For context why I hit this: [SourceKit-LSP](https://github.com/swiftlang/sourcekit-lsp) launches subprocesses to perform background indexing. When it shuts down, it should ensure that it doesn’t leave any orphan processes behind, and defaults to killing/terminating (on Posix vs Windows resp.) unresponsive subprocesses. But processes like swift-build might have spawned their own children, which would not be affected by their parent’s termination, leaving them running parentless.

---

_[View the full topic](https://forums.swift.org/t/review-3rd-sf-0007-subprocess/78078)._
