Skip to content

signals: Adds ContextWithHUP - #144

Merged
cicoyle merged 7 commits into
dapr:mainfrom
JoshVanL:signals-sighup
Mar 3, 2026
Merged

cicoyle merged 7 commits into
dapr:mainfrom
JoshVanL:signals-sighup

Conversation

@JoshVanL

Copy link
Copy Markdown
Member

Adds ContextWithHUP to create a context that is canceled when a SIGHUP signal is received. This allows applications to gracefully handle configuration reloads or other actions triggered by SIGHUP without needing to manage signal handling

On Windows, where SIGHUP is not available, ContextWithHUP is a no-op and returns the original context.

Adds ContextWithHUP to create a context that is canceled when a SIGHUP
signal is received. This allows applications to gracefully handle
configuration reloads or other actions triggered by SIGHUP without
needing to manage signal handling

On Windows, where SIGHUP is not available, ContextWithHUP is a no-op
and returns the original context.

Signed-off-by: joshvanl <me@joshvanl.dev>
Copilot AI review requested due to automatic review settings February 28, 2026 17:04
@JoshVanL
JoshVanL requested review from a team as code owners February 28, 2026 17:04
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.69%. Comparing base (d5a23c2) to head (c682454).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #144      +/-   ##
==========================================
+ Coverage   70.99%   71.69%   +0.69%     
==========================================
  Files          85       89       +4     
  Lines        5931     6017      +86     
==========================================
+ Hits         4211     4314     +103     
+ Misses       1550     1528      -22     
- Partials      170      175       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a ContextWithHUP helper to the signals package to support canceling a context on SIGHUP (for POSIX), with a Windows no-op implementation, enabling apps to react to HUP without bespoke signal wiring.

Changes:

  • Add ContextWithHUP(ctx) on POSIX that cancels when SIGHUP is received.
  • Add Windows no-op ContextWithHUP(ctx) implementation.
  • Expand POSIX tests to cover SIGTERM cancellation and verify context.Cause contains signal info; add tests for ContextWithHUP.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
signals/signals_posix.go Implements ContextWithHUP with signal.Notify + goroutine cancellation on SIGHUP.
signals/signals_windows.go Adds ContextWithHUP as a Windows no-op returning the input context.
signals/signals_posix_test.go Adds coverage for SIGTERM, cancellation cause content, and SIGHUP-driven cancellation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread signals/signals_posix.go Resolved
Comment thread signals/signals_posix.go Resolved
Comment thread signals/signals_posix.go Resolved
missed.

Signed-off-by: joshvanl <me@joshvanl.dev>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread signals/signals_posix.go Resolved
Comment thread signals/signals_posix.go Resolved
Signed-off-by: joshvanl <me@joshvanl.dev>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread signals/signals_posix.go Resolved
Comment thread signals/signals_windows.go Resolved
JoshVanL and others added 2 commits February 28, 2026 17:36
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Josh van Leeuwen <me@joshvanl.dev>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Josh van Leeuwen <me@joshvanl.dev>
Comment thread signals/signals_posix.go Resolved
Comment thread signals/signals_posix_test.go Resolved
cancel

Signed-off-by: joshvanl <me@joshvanl.dev>
Comment thread signals/signals_posix.go Resolved
Signed-off-by: joshvanl <me@joshvanl.dev>
@cicoyle
cicoyle merged commit b601f5b into dapr:main Mar 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants