cancel the context on SIGINT signal

This commit is contained in:
Gavin
2019-10-12 22:10:00 -04:00
parent 48fea4d008
commit 3c0d050d0a

11
gosh.go
View File

@@ -7,10 +7,12 @@ import (
"fmt"
"io/ioutil"
"os"
"os/signal"
"path"
"plugin"
"regexp"
"strings"
"syscall"
"github.com/vladimirvivien/gosh/api"
)
@@ -184,7 +186,10 @@ func main() {
}
}(shell.ctx, shell)
// wait
// TODO: sig handling
select {}
sigs := make(chan os.Signal)
signal.Notify(sigs, syscall.SIGINT)
select {
case <-sigs:
cancel()
}
}