Fix how processes are killed on Linux
This commit is contained in:
parent
06cfdcaf23
commit
8cdc6da20b
|
|
@ -27,7 +27,6 @@ namespace Microsoft.AspNetCore.Server.Testing
|
||||||
|
|
||||||
private readonly Stopwatch _stopwatch = new Stopwatch();
|
private readonly Stopwatch _stopwatch = new Stopwatch();
|
||||||
|
|
||||||
|
|
||||||
public ApplicationDeployer(DeploymentParameters deploymentParameters, ILogger logger)
|
public ApplicationDeployer(DeploymentParameters deploymentParameters, ILogger logger)
|
||||||
{
|
{
|
||||||
DeploymentParameters = deploymentParameters;
|
DeploymentParameters = deploymentParameters;
|
||||||
|
|
@ -127,26 +126,34 @@ namespace Microsoft.AspNetCore.Server.Testing
|
||||||
|
|
||||||
private void KillProcess(int processId)
|
private void KillProcess(int processId)
|
||||||
{
|
{
|
||||||
ProcessStartInfo startInfo;
|
|
||||||
|
|
||||||
if (IsWindows)
|
if (IsWindows)
|
||||||
{
|
{
|
||||||
startInfo = new ProcessStartInfo
|
var startInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = "taskkill",
|
FileName = "taskkill",
|
||||||
Arguments = $"/T /F /PID {processId}",
|
Arguments = $"/T /F /PID {processId}",
|
||||||
};
|
};
|
||||||
|
var killProcess = Process.Start(startInfo);
|
||||||
|
killProcess.WaitForExit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
startInfo = new ProcessStartInfo
|
var killSubProcessStartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = "pkill",
|
FileName = "pkill",
|
||||||
Arguments = $"-TERM -P {processId}",
|
Arguments = $"-TERM -P {processId}",
|
||||||
};
|
};
|
||||||
|
var killSubProcess = Process.Start(killSubProcessStartInfo);
|
||||||
|
killSubProcess.WaitForExit();
|
||||||
|
|
||||||
|
var killProcessStartInfo = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "kill",
|
||||||
|
Arguments = $"-TERM {processId}",
|
||||||
|
};
|
||||||
|
var killProcess = Process.Start(killProcessStartInfo);
|
||||||
|
killProcess.WaitForExit();
|
||||||
}
|
}
|
||||||
var killProcess = Process.Start(startInfo);
|
|
||||||
killProcess.WaitForExit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AddEnvironmentVariablesToProcess(ProcessStartInfo startInfo)
|
protected void AddEnvironmentVariablesToProcess(ProcessStartInfo startInfo)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue