-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Adding Kill(bool entireProcessTree) -- terminates a process tree #34147
Conversation
…ludes eliminating the output parameter
…luded in Uap and NetFx builds
…ify that it works)
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
@dotnet-bot please test Windows x64 Debug Build |
@dotnet-bot test NETFX x86 Release Build please (AV in csc .. bit worrying, but no diagnostics) |
@wtgodbe do you have any further feedback? |
This branch still has an old Helix SDK, that is why we're hitting the RestApiException. I'll retry the failing leg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minus the 2 nitpicks
@tmds any remaining feedback? |
@dotnet-bot build corefx-ci please |
Note that to trigger corefx-ci comments are broken. It is a known issue and we're waiting for a fix. It is probable that the build will fail. It seems like if you want it working, you will need to rebase or merge with master. Since all other builds are green and corefx-ci covers the same builds. We can ignore it in this PR since it is fairly old. |
This has been open long enough and scrutinized enough 😃 Thanks a lot @bgribaudo for the contribution. As you can see, usually community PR's go through much faster. I guess it was several reasons including the fiddly change. I hope it does not deter you from contributing in future. We have lots of issues labeled up for grabs. |
Thanks @bgribaudo |
…net/corefx#34147) * Adding Kill(bool entireProcessTree) * Slightly cleaning up NtQueryInformationProcess interop code * Trimming down PROCESSINFOCLASS enum members * Refactoring--adjusting indents, changing param from ref to out, etc. * Revising NtQueryInformationProcess-related code * Comment & indentation tweaks * TryGetParentProcessId -> GetParentProcessId rename/refactoring -- includes eliminating the output parameter * Removing UAP double-definition of KillTree() * Moving code so that not included in Uap build & tests so that not included in Uap and NetFx builds * Moving relevant code from Windows -> Win32 * Moving relevant code from Windows -> Win32 * Working to satisfy contract for Uap (code written to fail test to verify that it works) * Typo fix (missing return signature) * Removing unneeded Uap-specific test file * Adding temp. test to verify that UAP CI is catching test failures. * Using lists (vs. enumerables) as test assert arguments * Giving Kill() a moment to take effect * Removing whitespace * Removing irrelevant comment * Revising initial check that ensures process has started. * Moving process tree creation outside of finally * Adding retry logic to tests * Adjusting retry times/delay * Adding backoff to retry helper * Introducing non-auto-dispose variant of CreateProcess; refactoring * Improving exception handling * Moving catch * Minor refactoring/reformatting * Testing test execution by CI * Partially removing code testing CI system * Experimenting with implementing on OSX * Adding cast * Re-adding [ActiveIssue] attribute accidentally removed * Re-adding inadvertently-removed commented-out test attributes * Allowing aggregated Win32Exceptions to propagate out; disallowing calling Kill(true) on tree containing caller * Adjusting test attributes, removing CI verification test, adjusting expected exception * Marking non-local process test as platform-specific * Adding PlatformNotSupported throw for Uap. * Adding missing closing XML tag * XML doc tag tweak * Cleaning up two merge artifacts (whitespace + comment) * Adding console output for debugging * Fixing typo * Removing logging to console * Removing unused parameter * Unix & OSX exception tweaks * Variable rename * Whitespace tweak * Refactoring IsInTreeOf to use @danmosemsft's optimization suggestion; Renaming method * Missed a rename * Tweaking * Reworking IsSelfOrDescendant to use refactored GetChildProcesses * Minor fix * Applying minor tweaks suggested by @krwq * Adding a delay safety cutoff to RetryWithBackoff per @krwq's suggestion. * Adjusting backoff delay max to 10 seconds. * IsSelfOrDescendant -> IsSelfOrDescendantOf * Unix: If Stop() fails, don't try to continue with the process (thanks @tmds!). * Fixing typo. * Adding comments about kill/stop returning before termination/stopping completes. * Adding comment. Commit migrated from dotnet/corefx@81bd671
[Implements API approved by #26234]
Summary
When
Kill(bool entireProcessTree)
's argument is false, behaves identical toKill()
; when true, terminates the current process and all descendant processes (children, grandchildren, etc.).Platform Implementation Status
Implemented for Windows, OSX and Linux; not implemented for UAP, UnknownUnix or FreeBSD.
Notes
Potential low-hanging fruit: Behind-the-scenes, the logic in this PR enumerates child processes. This functionality could be leveraged to easily implement #25855.
Windows-specific logic inspired by msbuild's NativeMethodsShared KillTree.
[This PR replaces #31827]