Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6dd5b0d

Browse files
committedFeb 20, 2025·
Address first round of comments
1 parent a1cecf9 commit 6dd5b0d

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed
 

‎src/os/signal/signal_test.go

+9-17
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,10 @@ func TestResetIgnore(t *testing.T) {
921921
if err != nil {
922922
t.Fatalf("failed to parse signal: %v", err)
923923
}
924-
resetIgnoreTestProgram(syscall.Signal(s))
924+
if Ignored(syscall.Signal(s)) {
925+
os.Exit(1)
926+
}
927+
os.Exit(0)
925928
}
926929

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

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

970-
func resetIgnoreTestProgram(sig os.Signal) {
971-
if Ignored(sig) {
972-
os.Exit(1)
973-
}
974-
os.Exit(0)
975-
}
976-
977971
// #46321 test Reset correctly undoes the effect of Ignore when the child
978972
// process is started with a signal ignored.
979973
func TestInitiallyIgnoredResetIgnore(t *testing.T) {
@@ -1000,10 +994,8 @@ func TestInitiallyIgnoredResetIgnore(t *testing.T) {
1000994
cmd := testenv.Command(t, testenv.Executable(t), "-test.run=^TestInitiallyIgnoredResetIgnore$")
1001995
cmd.Env = append(os.Environ(), "GO_TEST_INITIALLY_IGNORED_RESET_IGNORE="+strconv.Itoa(int(sig)))
1002996
err := cmd.Run()
1003-
if _, ok := err.(*exec.ExitError); ok {
1004-
t.Fatalf("expected %q to be ignored in child process", sig)
1005-
} else if err != nil {
1006-
t.Fatalf("child process failed to launch: %v", err)
997+
if err != nil {
998+
t.Fatalf("expected %q to be ignored in child process: %v", sig, err)
1007999
}
10081000
})
10091001
}

‎src/runtime/signal_unix.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func sigenable(sig uint32) {
215215
// at program startup or the last custom handler registered by cgo.
216216
// It is only called while holding the os/signal.handlers lock,
217217
// via os/signal.disableSignal and signal_disable.
218-
// Returns true if the signal is ignored after the change.
218+
// Reports whether the signal is ignored after the change.
219219
func sigdisable(sig uint32) bool {
220220
if sig >= uint32(len(sigtable)) {
221221
return false

0 commit comments

Comments
 (0)
Please sign in to comment.