mirror of
https://github.com/whyvl/wireproxy.git
synced 2025-04-29 19:01:42 +02:00
feat: correct process sigint signal
This commit is contained in:
parent
9f533ac8b3
commit
d3a2aa8fb0
1 changed files with 12 additions and 1 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue