golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/quic/gotraceback_test.go (about)

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build go1.21 && unix
     6  
     7  package quic
     8  
     9  import (
    10  	"os"
    11  	"os/signal"
    12  	"runtime/debug"
    13  	"syscall"
    14  )
    15  
    16  // When killed with SIGQUIT (C-\), print stacks with GOTRACEBACK=all rather than system,
    17  // to reduce irrelevant noise when debugging hung tests.
    18  func init() {
    19  	ch := make(chan os.Signal, 1)
    20  	signal.Notify(ch, syscall.SIGQUIT)
    21  	go func() {
    22  		<-ch
    23  		debug.SetTraceback("all")
    24  		panic("SIGQUIT")
    25  	}()
    26  }