mirror of
https://github.com/MontFerret/ferret.git
synced 2025-08-15 20:02:56 +02:00
Fixed process termination by 'exit' word (#100)
This commit is contained in:
14
cli/repl.go
14
cli/repl.go
@@ -46,11 +46,15 @@ func Repl(version string, opts Options) {
|
|||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, syscall.SIGHUP)
|
signal.Notify(c, syscall.SIGHUP)
|
||||||
|
|
||||||
|
exit := func() {
|
||||||
|
cancel()
|
||||||
|
l.Close()
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
<-c
|
<-c
|
||||||
cancel()
|
exit()
|
||||||
l.Close()
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -86,6 +90,12 @@ func Repl(version string, opts Options) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if query == "exit" {
|
||||||
|
exit()
|
||||||
|
os.Exit(0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
program, err := ferret.Compile(query)
|
program, err := ferret.Compile(query)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user