Prerequisites
Steps to reproduce
The problem isn't easy to reproduce, and I see it on Windows only - it may be specific to aborting a Read-Host call.
It may take several tries, suggesting some non-deterministic timing is at play, relating to when the finally block executes in relation to stopping the script.
Related: #19988
# Save to a file and run on *Windows*:
# Repeatedly run the following and press Ctrl-C when prompted.
# Then make sure that:
# (a) 'Aborted.' prints
# and (b) that file temp:/$PID.txt exists.
Remove-Item -ErrorAction Ignore temp:/$PID.txt
try {
Read-Host 'Press Ctrl-C now'
}
finally {
Write-Host "Aborted."
Get-Date > temp:/$PID.txt
}
Expected behavior
Aborted. should print.
Running Get-Content temp:/$PID.txt afterwards should print the timestamp when Ctrl-C was pressed.
Actual behavior
Intermittently, Aborted. doesn't print.
More often, file temp:/$PID.txt isn't created.
The failure is always quiet.
Error details
No response
Environment data
PowerShell 7.4.0-preview.4 on Windows 11 22H2 (ARM64)
Visuals
No response
Prerequisites
Steps to reproduce
The problem isn't easy to reproduce, and I see it on Windows only - it may be specific to aborting a
Read-Hostcall.It may take several tries, suggesting some non-deterministic timing is at play, relating to when the
finallyblock executes in relation to stopping the script.Related: #19988
Expected behavior
Aborted.should print.Running
Get-Content temp:/$PID.txtafterwards should print the timestamp when Ctrl-C was pressed.Actual behavior
Intermittently,
Aborted.doesn't print.More often, file
temp:/$PID.txtisn't created.The failure is always quiet.
Error details
No response
Environment data
Visuals
No response