@@ -211,14 +211,14 @@ func sigenable(sig uint32) {
211
211
// sigdisable disables the Go signal handler for the signal sig.
212
212
// It is only called while holding the os/signal.handlers lock,
213
213
// via os/signal.disableSignal and signal_disable.
214
- func sigdisable (sig uint32 ) {
214
+ func sigdisable (sig uint32 ) bool {
215
215
if sig >= uint32 (len (sigtable )) {
216
- return
216
+ return false
217
217
}
218
218
219
219
// SIGPROF is handled specially for profiling.
220
220
if sig == _SIGPROF {
221
- return
221
+ return false
222
222
}
223
223
224
224
t := & sigtable [sig ]
@@ -230,11 +230,20 @@ func sigdisable(sig uint32) {
230
230
// If initsig does not install a signal handler for a
231
231
// signal, then to go back to the state before Notify
232
232
// we should remove the one we installed.
233
- if ! sigInstallGoHandler (sig ) {
233
+ if sigInstallGoHandler (sig ) {
234
+ if atomic .Cas (& handlingSig [sig ], 0 , 1 ) {
235
+ atomic .Storeuintptr (& fwdSig [sig ], getsig (sig ))
236
+ setsig (sig , abi .FuncPCABIInternal (sighandler ))
237
+ }
238
+ return false
239
+ } else {
234
240
atomic .Store (& handlingSig [sig ], 0 )
235
- setsig (sig , atomic .Loaduintptr (& fwdSig [sig ]))
241
+ fs := atomic .Loaduintptr (& fwdSig [sig ])
242
+ setsig (sig , fs )
243
+ return fs == _SIG_IGN
236
244
}
237
245
}
246
+ return false
238
247
}
239
248
240
249
// sigignore ignores the signal sig.
0 commit comments