From 107f3c384ca05b29baaf3498978dffe0d9d64873 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 2 Feb 2022 15:14:56 +0100 Subject: [PATCH] main.go: call shClient.IsOpen() and exit early if closed in interrupt handler. --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index a621565..2740508 100644 --- a/main.go +++ b/main.go @@ -62,6 +62,11 @@ func run() { case <-interrupt: log.Println("Interrupt, closing") + if shClient.IsOpen() == false { + log.Println("ship client not connected, exiting...") + return + } + // Cleanly close the connection by sending a close message and then // waiting (with timeout) for the server to close the connection. shClient.SendCloseMessage()