diff --git a/src/ansiblelint/__main__.py b/src/ansiblelint/__main__.py index e9215ff112..ad5bc7e9c1 100755 --- a/src/ansiblelint/__main__.py +++ b/src/ansiblelint/__main__.py @@ -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__ @@ -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)) diff --git a/src/ansiblelint/constants.py b/src/ansiblelint/constants.py index 43117160a8..e1c136102d 100644 --- a/src/ansiblelint/constants.py +++ b/src/ansiblelint/constants.py @@ -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"