Skip to content

Commit ab6609f

Browse files
author
epeshk
committed
Added test for GetProcessById with killed process
1 parent e41f3aa commit ab6609f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,18 @@ public void TestGetProcessById()
11181118
Assert.Equal(_process.ProcessName, p.ProcessName);
11191119
}
11201120

1121+
[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
1122+
public void GetProcessById_KilledProcess_ThrowsArgumentException()
1123+
{
1124+
Process process = CreateDefaultProcess();
1125+
var handle = process.SafeHandle;
1126+
int processId = process.Id;
1127+
process.Kill();
1128+
process.WaitForExit(WaitInMS);
1129+
Assert.Throws<ArgumentException>(() => Process.GetProcessById(processId));
1130+
GC.KeepAlive(handle);
1131+
}
1132+
11211133
[Fact]
11221134
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")]
11231135
public void TestGetProcesses()

0 commit comments

Comments
 (0)