-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Adding Kill(bool entireProcessTree) -- best-effort attempt to terminate a process tree #31827
Conversation
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
If you want to try OSX without a local machine, you can use the CI system on this PR to try it... |
src/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationProcess.cs
Outdated
Show resolved
Hide resolved
src/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationProcess.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
src/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationProcess.cs
Outdated
Show resolved
Hide resolved
src/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationProcess.cs
Show resolved
Hide resolved
src/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationProcess.cs
Outdated
Show resolved
Hide resolved
src/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationProcess.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
src/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationProcess.cs
Outdated
Show resolved
Hide resolved
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.
Some comments on interop inline
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.cs
Outdated
Show resolved
Hide resolved
src/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
@danmosemsft, good idea--I'll give that a try. Thanks! |
Test build against .NET Framework is failing as you can see in the NETFX details link above. (Most of our tests we build and run against NETFX to double check we get the same results)
Of course NETFX does not have this new method. To fix this, please move your new tests into a new named ProcessTests.netcoreapp.cs. In the csproj, condition it like <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<Compile Include="ProcessTests.netcoreapp.cs" />
.. Now it will only build and run against .NET Core and not against .NET Framework. |
On OSX, Kill_EntireProcessTree_True_EntireTreeTerminated test is failing with this (again you can see by following Details link above and some more clicks)
Sounds like yo'ure going to have a shot at fixing this - if not, we need to disable the test for OSX. |
For Kill_EntireProcessTree_False_OnlyRootProcessTerminated there are two distinct failures In OSX
Looks like you got the right result but the assert is the wrong overload. You may want to use All the Linuxes have the same problem, but apparently the process isn't getting terminated either:
Hopefully you can debug that locally. @bgribaudo hope this gives you enough to make progress! Again, all this should be publicly accessible through the CI links above |
UWP build has
This is because in the UWP build Process class is Process.cs+Process.Uap.cs+Process.Windows.cs. If you want something to be Windows but not UWP it needs to be in Process.Win32.cs. You can figure this out by looking in the csproj. You can build the tree for UWP by using |
I can't remember, but I think that was some special case that you would not normally get when terminating yourself. |
The work item attempted to run 3x, all 3x it hit a "STATUS_STACK_OVERFLOW". While I agree it's way too much clicking, you can get from Jenkins to here: https://mc.dot.net/#/user/bgribaudo/pr~2Fjenkins~2Fdotnet~2Fcorefx~2Fmaster~2F/test~2Ffunctional~2Fcli~2F/122e1b7ace4a9497ebab9d3ee2a31b499abbc47c/workItem/System.Diagnostics.Process.Tests/wilogs and see this in the logs:
It actually even looks like Dumpling might have a .dmp waiting for you too! |
lol, Matt was faster than me 😁 |
Thanks, I have no idea how I did not get that when I clicked on it earlier. @bgribaudo maybe you can figure it out from code inspection.. |
It looks like it's due to https://github.com/dotnet/corefx/issues/31908 -- you ?accidentally removed the |
@danmosemsft
I'll work on it. :-) Probably won't get much done on it, though, until after the holiday next week. Hope you all have a great Thanksgiving! |
Sounds good. STill plenty of time for 3.0 🦃 🍽 |
What's status of this PR? I don't see update in last 2 weeks ... |
I'm going to try to pick it back up sometime between now and Christmas when I can find a lull in regular work. |
…ling Kill(true) on tree containing caller
…xpected exception
@dotnet-bot test this please |
1 similar comment
@dotnet-bot test this please |
@dotnet-bot test this please |
Is there a CI/build problem with the Linux arm Release, Linux x64 Release and Tizen armel Debug builds?
The errors for the two build groups where details are shown don't seem to have anything to do with code I've written or build instructions I've configured. |
For diagnosing what's going on with the Linux arm Release leg the log doesn't really help here. If the error is not transient we would need a repro environment. Maybe @safern knows more? @dotnet-bot test Linux arm Release Build |
cc @dotnet/dnceng please take a look at the failing legs. I'm not sure why they are failing and not even producing a log. |
@ViktorHofer taking a look... |
@ViktorHofer This one failed trying to tar up the build: https://ci.dot.net/job/dotnet_corefx/job/master/job/linux_arm_cross_release_prtest/18512/consoleFull This run: https://ci3.dot.net/job/dotnet_corefx/job/master/job/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/19695/ Centos.74.Amd64.Open -> Centos.7.Amd64.Open https://ci.dot.net/job/dotnet_corefx/job/master/job/tizen_armel_cross_debug_prtest/18383/ failed build looking for Tizen stuff. |
Thanks, @MattGal & @ViktorHofer. As far as I know, this PR doesn't change anything directly that should cause those failures. I'm trying to update to latest to see if that brings in build definition changes that fix these.... |
I think the queue updates were already done in 96572c1. This PR is presumably stuck with the ones from when it was created. @bgribaudo you could close this and make a new one if you want to get those tests to work. Seems that it's close to mergeable anyway. |
Thanks, @danmosemsft! I'll try that. |
[Implements API approved by #26234]
Summary
When
Kill(bool entireProcessTree)
's argument is false, behaves identical toKill()
; when true, makes a best-effort attempt to terminate the current process and all descendant processes (children, grandchildren, etc.).Platform Implementation Status
Implemented for Windows and Linux; not implemented for UAP, UnknownUnix or FreeBSD/OSX.
Looks easy to implement for OSX (comment added in Process.OSX.cs with implementation idea), just don't have an OSX system to test against.
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.