Finally finished
This commit is contained in:
parent
309b836931
commit
5b213eb72f
10 changed files with 112 additions and 60 deletions
|
@ -8,7 +8,9 @@ import (
|
|||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
"github.com/creack/pty"
|
||||
)
|
||||
|
@ -36,10 +38,22 @@ func SetupCMD(binaryLocation string) error {
|
|||
reader = bufio.NewScanner(f);
|
||||
go readCMD();
|
||||
|
||||
// Make sure cmd is killed when this program is
|
||||
go catchKillSignal();
|
||||
|
||||
// No problem
|
||||
return nil;
|
||||
}
|
||||
|
||||
/* Catch signals from this program to kill child */
|
||||
func catchKillSignal() {
|
||||
signalCatcher := make(chan os.Signal, 1)
|
||||
signal.Notify(signalCatcher, syscall.SIGINT, syscall.SIGTERM, syscall.SIGILL)
|
||||
<- signalCatcher;
|
||||
cmd.Process.Kill();
|
||||
os.Exit(0); // Without this the process never exits
|
||||
}
|
||||
|
||||
/* Continuously reads the next line up to 40960 bytes and forwards it to response */
|
||||
func readCMD() {
|
||||
var maxCapacity int = 40960;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue