Skip to content

Return exit code 1 on CTRL+C cancellation#3264

Merged
Mpdreamz merged 1 commit into
mainfrom
fix/ctrl-c-exit-code
May 7, 2026
Merged

Return exit code 1 on CTRL+C cancellation#3264
Mpdreamz merged 1 commit into
mainfrom
fix/ctrl-c-exit-code

Conversation

@Mpdreamz
Copy link
Copy Markdown
Member

@Mpdreamz Mpdreamz commented May 7, 2026

Why

When a user presses CTRL+C, the process was exiting with code 0, making it indistinguishable from a successful run. This caused CI pipelines and shell scripts to silently swallow user-initiated cancellations as if the build had succeeded.

What

CatchExceptionMiddleware now sets context.ExitCode = 1 before returning on the CTRL+C path, so cancellation always signals failure to the caller — without emitting a spurious global error log entry.

User-initiated cancellation should signal failure to the shell just like
any other abnormal exit, so CI and scripts don't silently swallow it.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@Mpdreamz Mpdreamz requested a review from a team as a code owner May 7, 2026 06:47
@Mpdreamz Mpdreamz added the bug label May 7, 2026
@Mpdreamz Mpdreamz requested a review from technige May 7, 2026 06:47
@Mpdreamz Mpdreamz added the bug label May 7, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fdb8642f-4683-4687-b517-3a2ffa32592c

📥 Commits

Reviewing files that changed from the base of the PR and between a310432 and e85c858.

📒 Files selected for processing (1)
  • src/tooling/docs-builder/Middleware/CatchExceptionMiddleware.cs

📝 Walkthrough

Walkthrough

This PR adds a single line to the OperationCanceledException handler in CatchExceptionMiddleware. When CTRL+C triggers cancellation, the middleware now explicitly sets context.ExitCode = 1 before returning. Previously, the cancellation path only logged the event and returned without setting an exit code, which left the process exit status unset.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: setting exit code 1 when CTRL+C cancellation occurs.
Description check ✅ Passed The description clearly explains the problem, the solution, and the specific implementation detail, all directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/ctrl-c-exit-code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Mpdreamz Mpdreamz merged commit 129a585 into main May 7, 2026
26 checks passed
@Mpdreamz Mpdreamz deleted the fix/ctrl-c-exit-code branch May 7, 2026 19:06
Mpdreamz added a commit that referenced this pull request May 11, 2026
Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants