Verify recorder identity once and retain original native process handles

This commit is contained in:
NINI
2026-10-07 01:22:46 +09:00
parent 1bb7ca68da
commit 160b595e2f
5 changed files with 28 additions and 18 deletions
+4 -4
View File
@@ -217,16 +217,16 @@ finally {
if (!$recorder.process.HasExited -and !$recorder.process.WaitForExit(($recorder.seconds+30)*1000)) {
$result.status='failed'; $result.recorderError='Recorder exceeded completion bound; own native process stopped before restoration'
$ready=Get-Content -LiteralPath (Join-Path $EvidenceDir "$($recorder.name).wav.ready.json") -Raw | ConvertFrom-Json
$native=Get-Process -Id $ready.recorderPid -ErrorAction SilentlyContinue
if ($native) { $native.Kill(); $native.WaitForExit() }
$native=$recorder.nativeProcess
if ($native -and !$native.HasExited) { $native.Kill(); $native.WaitForExit() }
$recorder.process.WaitForExit(10000) | Out-Null
if (!$recorder.process.HasExited) { $recorder.process.Kill(); $recorder.process.WaitForExit() }
}
$readyPath=Join-Path $EvidenceDir "$($recorder.name).wav.ready.json"
if (Test-Path -LiteralPath $readyPath) {
$ready=Get-Content -LiteralPath $readyPath -Raw | ConvertFrom-Json
$native=Get-Process -Id $ready.recorderPid -ErrorAction SilentlyContinue
if ($native) { $native.WaitForExit() }
$native=$recorder.nativeProcess
if ($native -and !$native.HasExited -and !$native.WaitForExit(10000)) { throw 'Own native recorder did not terminate' }
$commands.Add(@{command='recorder termination boundary';recorderPid=$ready.recorderPid;wrapperPid=$recorder.process.Id;nativeExited=$true;wrapperExited=$recorder.process.HasExited;utc=[DateTime]::UtcNow.ToString('o')})
}
}