Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: os/signal: enhance NotifyContext() to return a context with cancel cause #66032

Closed
27149chen opened this issue Feb 29, 2024 · 4 comments
Labels
Milestone

Comments

@27149chen
Copy link

Proposal Details

Currently, NotifyContext returns a context without cancel cause

func NotifyContext(parent context.Context, signals ...os.Signal) (ctx context.Context, stop context.CancelFunc) {
    ctx, cancel := context.WithCancel(parent)
    ...
}

It is better to return a cause so that we can know it is canceled by a signal
Like that:

func NotifyContext(parent context.Context, signals ...os.Signal) (ctx context.Context, stop context.CancelFunc) {
    ctx, cancel := context.WithCancelCause(parent)
    ...
}
@gopherbot gopherbot added this to the Proposal milestone Feb 29, 2024
@DeedleFake
Copy link

The cause should be a custom error implementation that gives access to the os.Signal that caused the notification.

@mateusz834
Copy link
Member

#60756 ?

@seankhliao
Copy link
Member

Duplicate of #60756

@seankhliao seankhliao marked this as a duplicate of #60756 Feb 29, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 29, 2024
@27149chen
Copy link
Author

closed due to duplicated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants