From 88188cac2c0c603d24377cd2b321f7cf9a2991e5 Mon Sep 17 00:00:00 2001 From: Tim Voronov Date: Thu, 11 Oct 2018 13:35:30 -0400 Subject: [PATCH] Fixed process termination by 'exit' word (#100) --- cli/repl.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cli/repl.go b/cli/repl.go index 5abc51d8..e58b0efd 100644 --- a/cli/repl.go +++ b/cli/repl.go @@ -46,11 +46,15 @@ func Repl(version string, opts Options) { c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGHUP) + exit := func() { + cancel() + l.Close() + } + go func() { for { <-c - cancel() - l.Close() + exit() } }() @@ -86,6 +90,12 @@ func Repl(version string, opts Options) { continue } + if query == "exit" { + exit() + os.Exit(0) + return + } + program, err := ferret.Compile(query) if err != nil {