docker / cli

The Docker CLI
Apache License 2.0
4.87k stars 1.91k forks source link

fix: force cli to exit after third sigint/sigterm #5171

Closed Benehiko closed 3 months ago

Benehiko commented 3 months ago

- What I did

Added a global signal handler for cases where context cancellation is not respected. This will force the CLI to exit after 3 attempts of sigint/sigterm.

⋊> ~/G/docker-cli on master ⨯ ./build/docker login                                                                                                                                          15:41:40
Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com/ to create one.
You can log in with your password or a Personal Access Token (PAT). Using a limited-scope PAT grants better security and is required for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/

Username: ^C^C^C
got 3 SIGTERM/SIGINTs, forcefully exiting

- How I did it

I register a go routine to catch further signals upon running a docker command. Docker plugin handling has its own signal handling and is excluded from this signal handler.

- How to verify it

Try with docker login since it's currently not respecting context cancellation.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 61.72%. Comparing base (70b53a0) to head (faf7647). Report is 31 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #5171 +/- ## ========================================== - Coverage 61.76% 61.72% -0.05% ========================================== Files 297 294 -3 Lines 20768 20772 +4 ========================================== - Hits 12828 12822 -6 - Misses 7024 7034 +10 Partials 916 916 ```