Skip to content

Commit

Permalink
Merge pull request #3710 from joostjager/fix-lncli-hang
Browse files Browse the repository at this point in the history
lncli: do not hang on ctrl-c
  • Loading branch information
joostjager committed Nov 12, 2019
2 parents 76c2b2c + 6c6bbdd commit c5fde97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion signal/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c5fde97

Please sign in to comment.