Skip to content

Commit 3d83b49

Browse files
committed
Fix test
1 parent d0e3a63 commit 3d83b49

File tree

6 files changed

+37
-12
lines changed

6 files changed

+37
-12
lines changed

src/os/signal/signal.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ func Notify(c chan<- os.Signal, sig ...os.Signal) {
168168
}
169169
}
170170

171-
// Reset undoes the effect of any prior calls to [Notify] for the provided
172-
// signals.
171+
// Reset undoes the effect of any prior calls to [Notify] or [Ignore] for the
172+
// provided signals.
173173
// If no signals are provided, all signal handlers will be reset.
174174
func Reset(sig ...os.Signal) {
175175
cancel(sig, disableSignal)

src/runtime/os3_plan9.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ Exit:
149149
func sigenable(sig uint32) {
150150
}
151151

152-
func sigdisable(sig uint32) {
152+
func sigdisable(sig uint32) bool {
153+
return false
153154
}
154155

155156
func sigignore(sig uint32) {

src/runtime/os_wasm.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func getfp() uintptr { return 0 }
142142

143143
func setProcessCPUProfiler(hz int32) {}
144144
func setThreadCPUProfiler(hz int32) {}
145-
func sigdisable(uint32) {}
145+
func sigdisable(uint32) bool { return false }
146146
func sigenable(uint32) {}
147147
func sigignore(uint32) {}
148148

src/runtime/signal_unix.go

+21-6
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ func sigenable(sig uint32) {
202202
enableSigChan <- sig
203203
<-maskUpdatedChan
204204
if atomic.Cas(&handlingSig[sig], 0, 1) {
205-
atomic.Storeuintptr(&fwdSig[sig], getsig(sig))
205+
h := getsig(sig)
206+
if h != _SIG_IGN {
207+
atomic.Storeuintptr(&fwdSig[sig], h)
208+
}
206209
setsig(sig, abi.FuncPCABIInternal(sighandler))
207210
}
208211
}
@@ -211,14 +214,14 @@ func sigenable(sig uint32) {
211214
// sigdisable disables the Go signal handler for the signal sig.
212215
// It is only called while holding the os/signal.handlers lock,
213216
// via os/signal.disableSignal and signal_disable.
214-
func sigdisable(sig uint32) {
217+
func sigdisable(sig uint32) bool {
215218
if sig >= uint32(len(sigtable)) {
216-
return
219+
return false
217220
}
218221

219222
// SIGPROF is handled specially for profiling.
220223
if sig == _SIGPROF {
221-
return
224+
return false
222225
}
223226

224227
t := &sigtable[sig]
@@ -230,11 +233,23 @@ func sigdisable(sig uint32) {
230233
// If initsig does not install a signal handler for a
231234
// signal, then to go back to the state before Notify
232235
// we should remove the one we installed.
233-
if !sigInstallGoHandler(sig) {
236+
if sigInstallGoHandler(sig) {
237+
if atomic.Cas(&handlingSig[sig], 0, 1) {
238+
h := getsig(sig)
239+
if h != _SIG_IGN && h != _SIG_DFL {
240+
atomic.Storeuintptr(&fwdSig[sig], h)
241+
}
242+
setsig(sig, abi.FuncPCABIInternal(sighandler))
243+
}
244+
return false
245+
} else {
234246
atomic.Store(&handlingSig[sig], 0)
235-
setsig(sig, atomic.Loaduintptr(&fwdSig[sig]))
247+
fs := atomic.Loaduintptr(&fwdSig[sig])
248+
setsig(sig, fs)
249+
return fs == _SIG_IGN
236250
}
237251
}
252+
return false
238253
}
239254

240255
// sigignore ignores the signal sig.

src/runtime/signal_windows.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ func initsig(preinit bool) {
434434
func sigenable(sig uint32) {
435435
}
436436

437-
func sigdisable(sig uint32) {
437+
func sigdisable(sig uint32) bool {
438+
return false
438439
}
439440

440441
func sigignore(sig uint32) {

src/runtime/sigqueue.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,19 @@ func signal_disable(s uint32) {
230230
if s >= uint32(len(sig.wanted)*32) {
231231
return
232232
}
233-
sigdisable(s)
233+
ignored := sigdisable(s)
234234

235235
w := sig.wanted[s/32]
236236
w &^= 1 << (s & 31)
237237
atomic.Store(&sig.wanted[s/32], w)
238+
239+
i := sig.ignored[s/32]
240+
if ignored {
241+
i |= 1 << (s & 31)
242+
} else {
243+
i &^= 1 << (s & 31)
244+
}
245+
atomic.Store(&sig.ignored[s/32], i)
238246
}
239247

240248
// Must only be called from a single goroutine at a time.

0 commit comments

Comments
 (0)