Skip to content

Commit

Permalink
Improve ctrl-c exit (#1435)
Browse files Browse the repository at this point in the history
Avoid displaying stack-tracke on Ctrl-C and return standard exit code 130 for this case.
  • Loading branch information
ssbarnea authored Mar 6, 2021
1 parent b0bfc1c commit 9ddd2c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ansiblelint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
render_yaml,
)
from ansiblelint.config import options, used_old_tags
from ansiblelint.constants import ANSIBLE_MISSING_RC
from ansiblelint.constants import ANSIBLE_MISSING_RC, EXIT_CONTROL_C_RC
from ansiblelint.file_utils import cwd
from ansiblelint.skip_utils import normalize_tag
from ansiblelint.version import __version__
Expand Down Expand Up @@ -263,6 +263,8 @@ def _run_cli_entrypoint() -> None:
# NOTE: Only "broken pipe" is acceptable to ignore
if exc.errno != errno.EPIPE:
raise
except KeyboardInterrupt:
sys.exit(EXIT_CONTROL_C_RC)
except RuntimeError as e:
raise SystemExit(str(e))

Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ANSIBLE_FAILURE_RC = 3
ANSIBLE_MISSING_RC = 4
INVALID_PREREQUISITES_RC = 10
EXIT_CONTROL_C_RC = 130

# Minimal version of Ansible we support for runtime
ANSIBLE_MIN_VERSION = "2.9"
Expand Down

0 comments on commit 9ddd2c3

Please sign in to comment.