exithook

Imports

Imports #

"internal/runtime/atomic"
_ "unsafe"

Constants & Variables

Goid var #

var Goid func() uint64

Gosched var #

runtime sets these for us

var Gosched func()

Throw var #

var Throw func(string)

hooks var #

var hooks []Hook

locked var #

var locked atomic.Int32

runGoid var #

var runGoid atomic.Uint64

running var #

var running bool

Type Aliases

exitError type #

type exitError string

Structs

Hook struct #

A Hook is a function to be run at program termination (when someone invokes os.Exit, or when main.main returns). Hooks are run in reverse order of registration: the first hook added is the last one run.

type Hook struct {
F func()
RunOnFailure bool
}

Functions

Add function #

Add adds a new exit hook.

func Add(h Hook)

Error method #

func (e exitError) Error() string

Run function #

Run runs the exit hooks. If an exit hook panics, Run will throw with the panic on the stack. If an exit hook invokes exit in the same goroutine, the goroutine will throw. If an exit hook invokes exit in another goroutine, that exit will block.

func Run(code int)

Generated with Arrow