Skip to content

Conversation

@bduffany
Copy link
Contributor

See comments in buildbuddy-io/buildbuddy#8326 - signal.Ignore() is "permanent" so Reset() has no effect.

// used as a library, reset the signal handlers after the process exits.
signal.Ignore(syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
defer signal.Reset(syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
sigCh := make(chan os.Signal, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure how relevant this is in practice, but should we set the channel size to something reasonably large (perhaps just the number of signals?) based on https://cs.opensource.google/go/go/+/refs/tags/go1.24.0:src/os/signal/signal.go;l=110-113;drc=b28b263a91e4fd4af6900e045cd35c2ed1d6e3ff?

Choose a reason for hiding this comment

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

If the channel is full, the notification is discarded silently: https://cs.opensource.google/go/go/+/refs/tags/go1.24.0:src/os/signal/signal.go;l=244-248;drc=b28b263a91e4fd4af6900e045cd35c2ed1d6e3ff. We are attempting to ignore signals anyway, so that's fine.

Copy link
Contributor Author

@bduffany bduffany Feb 14, 2025

Choose a reason for hiding this comment

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

That's my understanding as well - I actually wanted to use an unbuffered channel here to communicate that intent more clearly, but it triggered a nogo error with a message saying that this channel needs to be buffered to avoid dropping signals - which presumably helps in the majority of cases where people do want to be notified of signals.

@fmeum
Copy link
Contributor

fmeum commented Feb 18, 2025

@meteorcloudy @fweikert Could you review this?

@fweikert fweikert merged commit 58015c1 into bazelbuild:master Feb 18, 2025
2 checks passed
sluongng added a commit to buildbuddy-io/buildbuddy that referenced this pull request Feb 20, 2025
sluongng added a commit to buildbuddy-io/buildbuddy that referenced this pull request Feb 24, 2025
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.

4 participants