I have a very limited understanding of how resource management/garbage collection and similar things work in powershell.
My question is: is it okay to kill a process that has a running runspace?
start.ps1
$moduleOnePath = Join-Path $cwd "moduleOne.exe" -Resolve
$moduleTwoPath = Join-Path $cwd "moduleTwo.exe" -Resolve
$moduleOneProcess = Start-Process $moduleOnePath -PassThru
$moduleTwoProcess = Start-Process $moduleTwoPath -PassThru
$moduleOneProcess.WaitForExit()
$moduleTwoProcess.kill()
moduleTwo.exe (compiled from ps
script with this; only relevant part shown)
$runspace= [runspacefactory]::CreateRunspace()
$runspace.Open()
$powershell= [powershell]::Create()
$powershell.Runspace = $runspace
$powershell.AddScript({
while($true) {
sleep -s 1;
}
}) | Out-Null