-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
v2 bug: control-c does not kill process #941
Comments
This is a command line argument parsing library, not a process lifetime management library, and the user of the library should handle this themselves. Essentially, I think it's the right decision not to handle this for the user, as this takes away the ability for the user to handle graceful termination. |
While i agree that process lifetime is outside this libs responsibility, I cannot find any way to pass a parent context into this lib (that can be cancelled as part of the lifetime). What is the correct way to implement a context-based terminate signal? |
Yeah, it seems the API is lack-luster. Perhaps there should be RunWithContext. |
This is what I ended up adding:
|
@bonesyo I really really don't want to go that way since i depend on my defer's in all running go-routines to actually shut things down correctly. I admit to put a panic on a timer to be sure there is an actual termination if something go wrong, but os.Exit will never close or flush or sync anything, and I need SIGTERM to be a normal way to terminate when a subcommand is a server-thing. @AudriusButkevicius that would solve things for me. |
FYI there is a RunWithContext now |
Super!! Ref #945 |
Checklist
Describe the bug
When a creating even a simple long running process, you can no longer use control-c to kill the process.
To reproduce
Expected behavior
Process to terminate when hitting control-c
Additional context
control-c works when using v1 release, but not v2
Want to fix this yourself?
We'd love to have more contributors on this project! If the fix for this bug is easily explained and very small, free free to create a pull request for it.
Run
go env
and paste its output hereThe text was updated successfully, but these errors were encountered: