From 000516ec4d0e331bc7b8ad35a595dd9a5529b9f8 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 17 Mar 2021 22:40:12 +0200 Subject: [PATCH] lncli: start signal interceptor in getContext signal Intercept function needs to be called if the signal shutdown channel will be listened on. --- cmd/lncli/cmd_open_channel.go | 4 ---- cmd/lncli/commands.go | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/lncli/cmd_open_channel.go b/cmd/lncli/cmd_open_channel.go index 15b0db80..c3471ae1 100644 --- a/cmd/lncli/cmd_open_channel.go +++ b/cmd/lncli/cmd_open_channel.go @@ -436,10 +436,6 @@ func openChannelPsbt(rpcCtx context.Context, ctx *cli.Context, 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 // 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. diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index 44450c13..5e6e3be7 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -41,6 +41,11 @@ const ( ) func getContext() context.Context { + if err := signal.Intercept(); err != nil { + _, _ = fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } + ctxc, cancel := context.WithCancel(context.Background()) go func() { <-signal.ShutdownChannel()