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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/akamensky/argparse"
|
"github.com/akamensky/argparse"
|
||||||
|
@ -46,6 +48,15 @@ func executablePath() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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()
|
exePath := executablePath()
|
||||||
unveilOrPanic("/", "r")
|
unveilOrPanic("/", "r")
|
||||||
unveilOrPanic(exePath, "x")
|
unveilOrPanic(exePath, "x")
|
||||||
|
@ -138,5 +149,5 @@ func main() {
|
||||||
go spawner.SpawnRoutine(tnet)
|
go spawner.SpawnRoutine(tnet)
|
||||||
}
|
}
|
||||||
|
|
||||||
select {} // sleep eternally
|
<-ctx.Done()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue