From e64df67ec397795b8c6ebd06b391d953afe5a766 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 24 Apr 2018 16:51:40 +0300 Subject: Everything is no longer broken --- gomuks.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gomuks.go') diff --git a/gomuks.go b/gomuks.go index ffdfad3..5f5d74b 100644 --- a/gomuks.go +++ b/gomuks.go @@ -18,7 +18,9 @@ package main import ( "os" + "os/signal" "path/filepath" + "syscall" "time" "maunium.net/go/gomuks/config" @@ -104,6 +106,13 @@ func (gmx *Gomuks) Stop() { func (gmx *Gomuks) Start() { _ = gmx.matrix.InitClient() + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt, syscall.SIGTERM) + go func() { + <-c + gmx.Stop() + }() + go gmx.StartAutosave() if err := gmx.ui.Start(); err != nil { panic(err) -- cgit v1.2.3