Properly exit listening mode if Ctrl+C is pressed.

v0.9
Martin Dosch 3 months ago
parent 27c45a1877
commit e5cbe832e3
No known key found for this signature in database
GPG Key ID: 52A57CFCE13D657D

@ -3,6 +3,7 @@
## UNRELEASED
### Changed
- Properly close stream if `Ctrl+C` is pressed in interactive mode.
- Properly close stream if `Ctrl+C` is pressed in listening mode.
- Print OS, architecture and go version for flag `--version`.
- Improve closing of connection.

@ -38,6 +38,7 @@ func closeAndExit(client *xmpp.Client, cancel context.CancelFunc, err error) {
if err != nil {
log.Fatal(err)
}
os.Exit(0)
}
func readMessage(messageFilePath string) (string, error) {
@ -519,6 +520,14 @@ func main() {
}
case *flagListen:
tz := time.Now().Location()
// Quit if ^C is pressed.
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
for range c {
closeAndExit(client, cancel, nil)
}
}()
for {
v := <-msgc
switch {

Loading…
Cancel
Save