mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-20 19:16:47 +01:00
signal: handle shutdown properly
This addresses issues related to the mobile lnd builds, where calling `stopDaemon` and subsequently calling LndMobile's `Start` results in crash.
This commit is contained in:
@@ -41,14 +41,15 @@ const (
|
||||
)
|
||||
|
||||
func getContext() context.Context {
|
||||
if err := signal.Intercept(); err != nil {
|
||||
shutdownInterceptor, err := signal.Intercept()
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
ctxc, cancel := context.WithCancel(context.Background())
|
||||
go func() {
|
||||
<-signal.ShutdownChannel()
|
||||
<-shutdownInterceptor.ShutdownChannel()
|
||||
cancel()
|
||||
}()
|
||||
return ctxc
|
||||
|
||||
Reference in New Issue
Block a user