github.com/puellanivis/breton@v0.2.16/lib/util/context.go (about) 1 package util 2 3 import ( 4 "context" 5 6 "github.com/puellanivis/breton/lib/os/process" 7 ) 8 9 // HangupChannel provides a receiver channel that will notify the caller of when a SIGHUP signal has been received. 10 // This signal is often used by daemons to be notified of a request to reload configuration data. 11 // 12 // Note, that if too many SIGHUPs arrive at once, and the signal handler would block trying to send this notification, 13 // then it will treat the signal the same as any other terminating signals. 14 func HangupChannel() <-chan struct{} { 15 return process.HangupChannel() 16 } 17 18 // Context returns a context.Context that will cancel if the program receives any signal that a program may want to cleanup after. 19 func Context() context.Context { 20 return process.Context() 21 } 22 23 // Quit causes a closure of the signal channel, which causes the signal handler 24 // to cancel the util.Context() context, leading to a (hopefully) graceful-ish 25 // shutdown of the program. 26 func Quit() { 27 process.Quit() 28 }