A program asks to handle SIGKILL or SIGSTOP, which never reach it

tx0/go:uncatchable-signaldefaultwarningbug

What it finds

signal.Notify(c, os.Kill): the operating system stops or kills a process on SIGKILL and SIGSTOP without telling it, so asking to be notified of them, or to ignore them, has no effect, and cleanup that waits for them never runs.

Reported are the arguments os.Kill, syscall.SIGKILL and syscall.SIGSTOP, and the same names of golang.org/x/sys/unix, given to Notify, Ignore or Reset of os/signal, resolved through the imports.

From the rule's source, uncatchable_signal.rs.

Example from the rule's tests
package p import (	"os"	"os/signal"	"syscall") func f() chan os.Signal {	c := make(chan os.Signal, 1)	signal.Notify(c, os.Interrupt, os.Kill)tx0 reports: os.Kill cannot be caught	signal.Notify(c, syscall.SIGTERM, syscall.SIGSTOP)tx0 reports: syscall.SIGSTOP cannot be caught	signal.Ignore(syscall.SIGKILL)tx0 reports: syscall.SIGKILL cannot be caught	signal.Notify(c, syscall.SIGHUP)	return c}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/go:uncatchable-signal" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/go:uncatchable-signal] reason="..."

tx0 explain tx0/go:uncatchable-signal shows the same in the terminal. Found a false positive? Report it.