.Net 8 -> Killing entire tree not working using Process.Kill(true)
TejasPatadiya10 opened this issue · comments
Below is my simple code :
static void Main(string[] args)
{
while (true)
{
try
{
Process.Start(new ProcessStartInfo() { FileName= "ChildProcess.exe" });
Thread.Sleep(5000);
Process.GetCurrentProcess().Kill(true);// this line always give exception : {"Cannot be used to terminate a process tree containing the calling process."
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
The above code should kill the child process and the main process but it always results in exception : "Cannot be used to terminate a process tree containing the calling process."
I am not sure its BUG or anything else.
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.
Duplicate of #85383