Finally finished

This commit is contained in:
Ben 2025-08-01 15:16:25 -07:00
parent 309b836931
commit 5b213eb72f
Signed by: webmaster
GPG key ID: A5FCBAF34E6E8B50
10 changed files with 112 additions and 60 deletions

View file

@ -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;