Merge pull request #3710 from joostjager/fix-lncli-hang

lncli: do not hang on ctrl-c
This commit is contained in:
Joost Jager 2019-11-12 22:04:13 +01:00 committed by GitHub
commit c5fde97d12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

3
lnd.go

@ -116,6 +116,9 @@ type rpcListeners func() ([]net.Listener, func(), []grpc.ServerOption, error)
// created in the top-level scope of a main method aren't executed if os.Exit()
// is called.
func Main(lisCfg ListenerCfg) error {
// Hook interceptor for os signals.
signal.Intercept()
// Load the configuration, and parse any command line options. This
// function will also set up logging properly.
loadedConfig, err := loadConfig()

@ -26,7 +26,8 @@ var (
shutdownChannel = make(chan struct{})
)
func init() {
// Intercept starts the interception of interrupt signals.
func Intercept() {
signalsToCatch := []os.Signal{
os.Interrupt,
os.Kill,