-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Open
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group
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
try
{
echo Sleeping...
Start-Sleep 5
echo Exiting...
}
finally {
echo Finally...
echo "Exit code: $LASTEXITCODE"
}Running it: conhost cmd /k pwsh -f test.ps1, then hitting Ctrl+C after Sleeping... shows up, I only see Finally... about 1 out 10 runs.
Expected behavior
The following output should be consistently displayed:
Finally...
Exit code: 0
### Actual behavior
```console
In most cases (but not always), `finally` block doesn't get executed when Ctrl+C is pressed in the middle of `Start-Sleep` execution.
Error details
N/AEnvironment data
❯ $PSVersionTable
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
### Visuals
_No response_
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group