Skip to content

Process.GetProcessById claims killed process is still alive in .NET Core #63937

@bouchraRekhadda

Description

@bouchraRekhadda

Description

Process.GetProcessById should throw an ArgumentException if the process isn't running, but it doesn't seem to be the case with .NET Core 3.1 as the method always returns previously killed process (please check repro below).
Am I missing something ?

Reproduction Steps

        [Test] public void TestKillProcess()
        {
            var p = new Process();
            p.StartInfo.FileName = "cmd.exe";
            p.Start();
            var pid = p.Id;
            p.Kill();
            Assert.Throws<ArgumentException>(() => Process.GetProcessById(pid));
        }

Expected behavior

Test should pass as in .NET Framework 4.8

Actual behavior

Test fails
image

Regression?

It works on .NET Framework 4.8.

Configuration

  • .NET Core 3.1
  • Windows 10
  • x64

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions