MCPcopy Create free account
hub / github.com/akash-network/node / trapSignal

Function trapSignal

testutil/network/network.go:458–479  ·  view source on GitHub ↗

trapSignal traps SIGINT and SIGTERM and calls os.Exit once a signal is received.

(cleanupFunc func())

Source from the content-addressed store, hash-verified

456
457// trapSignal traps SIGINT and SIGTERM and calls os.Exit once a signal is received.
458func trapSignal(cleanupFunc func()) {
459 sigs := make(chan os.Signal, 1)
460 signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
461
462 go func() {
463 sig := <-sigs
464
465 if cleanupFunc != nil {
466 cleanupFunc()
467 }
468 exitCode := 128
469
470 switch sig {
471 case syscall.SIGINT:
472 exitCode += int(syscall.SIGINT)
473 case syscall.SIGTERM:
474 exitCode += int(syscall.SIGTERM)
475 }
476
477 os.Exit(exitCode)
478 }()
479}
480
481// LatestHeight returns the latest height of the network or an error if the
482// query fails or no validators exist.

Callers 1

NewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected