Skip to content

Commit

Permalink
Address first round of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Feb 20, 2025
1 parent a1cecf9 commit 6dd5b0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
26 changes: 9 additions & 17 deletions src/os/signal/signal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,10 @@ func TestResetIgnore(t *testing.T) {
if err != nil {
t.Fatalf("failed to parse signal: %v", err)
}
resetIgnoreTestProgram(syscall.Signal(s))
if Ignored(syscall.Signal(s)) {
os.Exit(1)
}
os.Exit(0)
}

sigs := []syscall.Signal{
Expand All @@ -937,7 +940,7 @@ func TestResetIgnore(t *testing.T) {
for _, sig := range sigs {
t.Run(fmt.Sprintf("%s[notify=%t]", sig, notify), func(t *testing.T) {
if Ignored(sig) {
t.Fatalf("expected %q to not be ignored initially", sig)
t.Skipf("expected %q to not be ignored initially", sig)
}

Ignore(sig)
Expand All @@ -957,23 +960,14 @@ func TestResetIgnore(t *testing.T) {
cmd := testenv.Command(t, testenv.Executable(t), "-test.run=^TestResetIgnore$")
cmd.Env = append(os.Environ(), "GO_TEST_RESET_IGNORE="+strconv.Itoa(int(sig)))
err := cmd.Run()
if _, ok := err.(*exec.ExitError); ok {
t.Fatalf("expected %q to not be ignored in child process", sig)
} else if err != nil {
t.Fatalf("child process failed to launch: %v", err)
if err != nil {
t.Fatalf("expected %q to not be ignored in child process: %v", sig, err)
}
})
}
}
}

func resetIgnoreTestProgram(sig os.Signal) {
if Ignored(sig) {
os.Exit(1)
}
os.Exit(0)
}

// #46321 test Reset correctly undoes the effect of Ignore when the child
// process is started with a signal ignored.
func TestInitiallyIgnoredResetIgnore(t *testing.T) {
Expand All @@ -1000,10 +994,8 @@ func TestInitiallyIgnoredResetIgnore(t *testing.T) {
cmd := testenv.Command(t, testenv.Executable(t), "-test.run=^TestInitiallyIgnoredResetIgnore$")
cmd.Env = append(os.Environ(), "GO_TEST_INITIALLY_IGNORED_RESET_IGNORE="+strconv.Itoa(int(sig)))
err := cmd.Run()
if _, ok := err.(*exec.ExitError); ok {
t.Fatalf("expected %q to be ignored in child process", sig)
} else if err != nil {
t.Fatalf("child process failed to launch: %v", err)
if err != nil {
t.Fatalf("expected %q to be ignored in child process: %v", sig, err)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/signal_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func sigenable(sig uint32) {
// at program startup or the last custom handler registered by cgo.
// It is only called while holding the os/signal.handlers lock,
// via os/signal.disableSignal and signal_disable.
// Returns true if the signal is ignored after the change.
// Reports whether the signal is ignored after the change.
func sigdisable(sig uint32) bool {
if sig >= uint32(len(sigtable)) {
return false
Expand Down

0 comments on commit 6dd5b0d

Please sign in to comment.