-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Open
Labels
KeepOpenThe bot will ignore these and not auto-closeThe bot will ignore these and not auto-closeNeeds-InvestigationThe behavior reported in the issue is unexpected and needs further investigation.The behavior reported in the issue is unexpected and needs further investigation.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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
Metadata
Metadata
Assignees
Labels
KeepOpenThe bot will ignore these and not auto-closeThe bot will ignore these and not auto-closeNeeds-InvestigationThe behavior reported in the issue is unexpected and needs further investigation.The behavior reported in the issue is unexpected and needs further investigation.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Type
Projects
Status
Issue Todo