Merge pull request #5119 from ellemouton/lncli-start-signal-interceptor

lncli: start signal interceptor in getContext
This commit is contained in:
Johan T. Halseth 2021-03-18 09:30:11 +01:00 committed by GitHub
commit 6046c5cf86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

@ -436,10 +436,6 @@ func openChannelPsbt(rpcCtx context.Context, ctx *cli.Context,
return fmt.Errorf("opening stream to server failed: %v", err) return fmt.Errorf("opening stream to server failed: %v", err)
} }
if err := signal.Intercept(); err != nil {
return err
}
// We also need to spawn a goroutine that reads from the server. This // We also need to spawn a goroutine that reads from the server. This
// will copy the messages to the channel as long as they come in or add // will copy the messages to the channel as long as they come in or add
// exactly one error to the error stream and then bail out. // exactly one error to the error stream and then bail out.

@ -41,6 +41,11 @@ const (
) )
func getContext() context.Context { func getContext() context.Context {
if err := signal.Intercept(); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
ctxc, cancel := context.WithCancel(context.Background()) ctxc, cancel := context.WithCancel(context.Background())
go func() { go func() {
<-signal.ShutdownChannel() <-signal.ShutdownChannel()