From 0c12126daf8a43aced64d29ae3c017ad716fb06f Mon Sep 17 00:00:00 2001 From: KitsuneSemCalda Date: Sat, 27 Jan 2024 02:35:34 -0300 Subject: [PATCH] feat(main): adding capacity of signals kill the program --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.go b/main.go index 3b38a6b..b79ecc3 100644 --- a/main.go +++ b/main.go @@ -7,11 +7,26 @@ import ( tui "animatic-v2/Tui" utils "animatic-v2/Utils" "os" + "os/signal" "path/filepath" "runtime" + "syscall" ) func main() { + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGTERM, syscall.SIGKILL) + + go func() { + sig := <-sigs + switch sig { + case syscall.SIGTERM: + os.Exit(0) + case syscall.SIGKILL: + os.Exit(1) + } + }() + // If hasn't internet connection, break the program if network.HasNetwork() == false { message.ErrorMessage("Hasn't internet connection")