diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go index 7696fad99..2bca9dd45 100644 --- a/cmd/ipfs/main.go +++ b/cmd/ipfs/main.go @@ -481,15 +481,20 @@ func (i *cmdInvocation) setupInterruptHandler() { sig := allInterruptSignals() go func() { - // wait till the context is ready to be closed - <-ctx.InitDone - // first time, try to shut down. // loop because we may be for count := 0; ; count++ { <-sig + // if we're still initializing, cannot use `ctx.GetNode()` + select { + default: // initialization not done + fmt.Println("Received interrupt signal, shutting down...") + os.Exit(-1) + case <-ctx.InitDone: + } + // TODO cancel the command context instead n, err := ctx.GetNode()