From fe7d208cf76fa6f24bb9d12ba29b5ed61d837ce3 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 13 Feb 2025 23:15:34 +0900 Subject: helper: use generic extra files interface This replaces the pipes object and integrates context into helper process lifecycle. Signed-off-by: Ophestra --- main.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 1c6ab080..1ef11e1e 100644 --- a/main.go +++ b/main.go @@ -307,22 +307,14 @@ func main() { func runApp(config *fst.Config) { rs := new(app.RunState) - ctx, cancel := context.WithCancel(context.Background()) + ctx, stop := signal.NotifyContext(context.Background(), + syscall.SIGINT, syscall.SIGTERM) + defer stop() // unreachable if fmsg.Verbose() { seccomp.CPrintln = fmsg.Println } - // handle signals for graceful shutdown - sig := make(chan os.Signal, 2) - signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) - go func() { - v := <-sig - fmsg.Printf("got %s after program start", v) - cancel() - signal.Ignore(syscall.SIGINT, syscall.SIGTERM) - }() - if a, err := app.New(sys); err != nil { fmsg.Fatalf("cannot create app: %s\n", err) } else if err = a.Seal(config); err != nil { -- cgit v1.3.1