// Ignore causes the provided signals to be ignored. If they are received by
// the program, nothing will happen. Ignore undoes the effect of any prior
// calls to Notify for the provided signals.
// If no signals are provided, all incoming signals will be ignored.
so what it does is to iterate over signal.handlers.m, a package-level map variable that keeps track of all the signal -> channel that it needs to notify upon receiving a signal. Upon finding the right entries for the given signal, it will delete all the handlers for that signal.
This does not work for us because we have never called signal.Notify before signal.Ignore, thus the call to signal.Ignore deleted no handler and was effectively a no-ops. Using signal.Notify to first register a handler to capture the signal is the right fix.
In https://github.com/bazelbuild/rules_go/pull/3920, a new mechanism to handle test timeout was introduced. However this broke existing tests that use SIGTERM inside.
Restore the original behavior.
From the doc of
signal.Ignore
:so what it does is to iterate over
signal.handlers.m
, a package-level map variable that keeps track of all the signal -> channel that it needs to notify upon receiving a signal. Upon finding the right entries for the given signal, it will delete all the handlers for that signal.This does not work for us because we have never called
signal.Notify
beforesignal.Ignore
, thus the call tosignal.Ignore
deleted no handler and was effectively a no-ops. Usingsignal.Notify
to first register a handler to capture the signal is the right fix.Reference: https://cs.opensource.google/go/go/+/refs/tags/go1.22.2:src/os/signal/signal.go;l=86