Skip to content

PowerShell doesn't kill native child processes when StopProcessing is called on pipeline #2561

Description

The native command processor doesn't correctly kill child processes (only the parent) when Stop()/BeginStop() is called:

build createchildprocess from test\tools\CreateChildProcess

$cmd = "pathto\createchildprocess.exe"
$ps = [powershell]::create().Addcommand($cmd)
$ps.AddParameter(2) # this creates two children
$ps.BeginInvoke()
# verify that 3 instances of createchildprocess has started
$ps.Stop()

Expected:
parent and child process to be killed

Actual:
parent is killed and children are orphaned (they will eventually timeout and exit)

Repros on PS5.1, PSCore 6.0 Windows/Linux

Name                           Value
----                           -----
PSVersion                      5.1.14931.1000
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14931.1000
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions