-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terminating dotnet run
doesn't terminate child
#8610
Comments
Maybe using dumb-init could help with this? |
Maybe for containers. This is just using a plain |
Same problem with |
I'm tool, same problem. |
on @mickaelistria's case, about dotnet razor, I don't think it is dotnet's job to terminate those processes. The CTRL+C message there is coming from asp.net itself and when you CTRL+C it is asp.net's responsibility to terminate any extra processes that it may have initiated when it gets terminated. Also, I couldn't repro this right now when I tried. As for dotnet test, @psmolkin would you happen to have a repro for it? |
@livarcocc |
Steps to reproduce:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.2.0" />
</ItemGroup>
</Project>
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace Ap.Ms.Test
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
while (true)
{
Assert.IsTrue(true);
}
Assert.IsTrue(true);
}
}
} Expected
Actually
|
getting this with 2.1.0-preview2-26406-04, both on Linux and on Windows |
I have observed a similar beahoviour of not working Ctrl+C BUT only when using a hosted services. I used sample codes from https://github.com/aspnet/Docs/tree/master/aspnetcore/fundamentals/host/hosted-services/samples/, in time and scope variant, and this is repeatable and permanent behavior. |
And one observation more: when I press any key (e.g. "f") after Ctrl+C, than I see an error message (translated from Polish: "Name 'f' is not recognized as an internal or external command, exacutable or batch script."), and the process is terminating, without any other messages in console. It applies to SDK 2.1. |
I hit this in @coherenceApi on linux recently. I managed to work around it by using the method here. This is a var spawn = require('child_process').spawn;
var child = spawn('my-command', {detached: true});
process.kill(-child.pid); IMO the cli should be terminating the entire process group @livarcocc , but there should be an api for that in corefx (no idea if there is one). |
A few PowerShell (run as Administrator) one-liners to work around that:
Run at your own risk. |
I think it is reasonable to expect Still:
|
Looks like this thread is still active but stale. It was originally open almost a year ago: do we have consensus that this is real and should be addressed somewhere and slotted for a future release? |
I'd really like this to be fixed. I'm just getting into the dotnet platform and would really like to take advantage of the speed of linux over windows for our server, but in testing we keep running into this issue which putting us down a bit. How I encountered the issueSystemUbuntu 18.04.1 LTS 1 cpu, 1gb ram (AWS EC2 free tier) Install dotnet-sdk-2.1
Install Node.js
Create Angular / .net project
Start project
Wait for the angular build to finish. After this, kill the project with Ctrl + C. Sometimes it successfully says If you look in htop, it seems to be a bunch of ng processes which is strange. So maybe it is just something as simple as the ng serve is stuck open. You can see htop below. @omajid @livarcocc Hopefully this helps move this along in some way. |
If closing a asp.net app is not terminating the process, I believe this is an issue that should be investigated by the ASP.NET team. Please, file a new issue on aspnet/home. Another possibility is that dotnet has three long running processes that stay around to help with inner loop performance: roslyn, msbuild and razor. You can terminate these processes by running |
quoting from asp.net issue tracker:
|
@jkotas do you know if this is a limitation of the host or the process APIs? |
@livarcocc Killing parent process does not automatically kill child processes. It is standard behavior of process APIs in both .NET and elsewhere. For example, if you launch a child process using C/C++ system function, killing the parent process won't automatically kill the child process either. You can do a best effort to kill child process in A more reliable solution is to kill the process group in the first place. E.g. replace "kill -15 24040 #SIGTERM on host" in the repro above with "kill -15 -- -24040 #SIGTERM on host process group". |
Well, I've found a temporary solution to the problem. Again, it's TEMPORARY. It's wonky, but it works. |
I am considering making a fix that addresses this issue. On POSIX systems, On Windows, we could potentially create a job object, associate the new process to the job, and set the job object to terminate all processes in the job upon rude termination of Still, considering the fix would effectively translate the user action of |
You can pick up CTRL+C on Windows (C# Console.CancelKeyPress, implemented behind the scenes via kernel32.dll's SetConsoleCtrlHandler on Windows). |
Hi @herebebeasties. Consistent This issue is about sending |
We are seeing similar behavior with Task Scheduler in Windows. Scheduled run.bat which runs "dotnet foo.dll" in Task Scheduler with "Stop the task if it runs longer than: X". Past the time, we see "Task stopping due to timeout reached" in the History of the task but "dotnet foo.dll" continues to run and can be seen in Task Manager Details tab. Is this the same problem as this issue? Thanks! |
@Code-DJ Task Scheduler has been unreliable for ages. I've had better luck creating services that do this programatically. |
Steps to reproduce
Expected behavior
Child process terminated
Actual behavior
Child process is still there
This can be confusing for IDEs (like Eclipse IDE) which bind the "stop" button and other UI actions to the Terminate signal. In such case, the developer trying
dotnet run
from the IDE will face issues because of the zombi-ish processesEnvironment data
dotnet --info
output:The text was updated successfully, but these errors were encountered: