-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Program hangs when Environment.Exit is called from OnExecute #292
Comments
having the same issue here. |
downgrading to 2.4.0 fixes issue for me. |
Looks like a bug. Would be happy to have help investigating this. I'm low on free time these days |
@natemcmaster I can give it a try. Any idea where I should start looking? |
I see what the problem is. CommandLineUtils subscribe to void processExitHandler(object o, EventArgs e)
{
handlerCancellationTokenSource.Cancel();
handlerCompleted.Wait();
}
And as far as I can tell, there's no way to fix it... unless you don't wait for completion in the According to the documentation, in the .NET Framework, the Another option is to make this behavior optional. @natemcmaster what do you think? |
Apparentlly the problem was introduced in 3a86cab. Previously, |
Also, I think the handling of Ctrl-C is problematic. Now, Ctrl-C will stop execution only if OnExecute handles the cancellation token. At the very least, Ctrl-C handling should be suppressed if the OnExecute method doesn't accept a cancellation token. |
@thomaslevesque thanks for the investigation! This seems patch-worthy to me, so I've created a new branch called 'release/2.4.3'. If you have available time to make a PR, please use that branch. I'm also going to look into making some changes if I have time over the weekend. The original intent of the Ctrl-C handling was to allow time for async completions after ctrl+c is pressed. I think there are two changes we should make to the current implementation:
|
I'm not sure this is the right criteria.
So I think the only criteria should be that the
👍 |
👍 for the removal of processexit event. |
That's what I was originally thinking too, so I'm glad we're on the same page. The implementation of that gets a little tricky with the current code, so let's open a separate issue for this one. |
Describe the bug
The program hangs when
Environment.Exit(0)
is called fromOnExecute
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The program should terminate
Screenshots
N/A
Additional context
I know I don't need to call
Environment.Exit
, but it's called by the Bullseye library when I useRunTargetsAndExit
The text was updated successfully, but these errors were encountered: