@@ -422,6 +422,19 @@ func TestAtomicStop(t *testing.T) {
422
422
423
423
testenv .MustHaveExec (t )
424
424
425
+ // Call Notify for SIGINT before starting the child process.
426
+ // That ensures that SIGINT is not ignored for the child.
427
+ // This is necessary because if SIGINT is ignored when a
428
+ // Go program starts, then it remains ignored, and closing
429
+ // the last notification channel for SIGINT will switch it
430
+ // back to being ignored. In that case the assumption of
431
+ // atomicStopTestProgram, that it will either die from SIGINT
432
+ // or have it be reported, breaks down, as there is a third
433
+ // option: SIGINT might be ignored.
434
+ cs := make (chan os.Signal , 1 )
435
+ Notify (cs , syscall .SIGINT )
436
+ defer Stop (cs )
437
+
425
438
const execs = 10
426
439
for i := 0 ; i < execs ; i ++ {
427
440
timeout := "0"
@@ -466,6 +479,12 @@ func TestAtomicStop(t *testing.T) {
466
479
// It tries to trigger a signal delivery race. This function should
467
480
// either catch a signal or die from it.
468
481
func atomicStopTestProgram () {
482
+ // This test won't work if SIGINT is ignored here.
483
+ if Ignored (syscall .SIGINT ) {
484
+ fmt .Println ("SIGINT is ignored" )
485
+ os .Exit (1 )
486
+ }
487
+
469
488
const tries = 10
470
489
471
490
timeout := 2 * time .Second
0 commit comments