feat: correct process sigint signal

This commit is contained in:
Evsyukov Denis 2024-02-08 19:23:50 +03:00
parent 9f533ac8b3
commit d3a2aa8fb0
No known key found for this signature in database

View file

@ -1,10 +1,12 @@
package main
import (
"context"
"fmt"
"log"
"os"
"os/exec"
"os/signal"
"syscall"
"github.com/akamensky/argparse"
@ -46,6 +48,15 @@ func executablePath() string {
}
func main() {
s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGINT, syscall.SIGQUIT)
ctx, cancel := context.WithCancel(context.Background())
go func() {
<-s
cancel()
}()
exePath := executablePath()
unveilOrPanic("/", "r")
unveilOrPanic(exePath, "x")
@ -138,5 +149,5 @@ func main() {
go spawner.SpawnRoutine(tnet)
}
select {} // sleep eternally
<-ctx.Done()
}