diff options
| author | Paul Buetow <paul@buetow.org> | 2025-03-12 22:28:18 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-03-12 22:28:18 +0200 |
| commit | ac7ebea0920819a14e981da7e3297a8e2e256559 (patch) | |
| tree | fafd32d2b81cd23017048bfc6370230f2da5d572 /internal/ior.go | |
| parent | 2cf6f74135b830885bad25e4f6aba3e0e31581b8 (diff) | |
initial flames
Diffstat (limited to 'internal/ior.go')
| -rw-r--r-- | internal/ior.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/internal/ior.go b/internal/ior.go index 76cf17d..62e25ef 100644 --- a/internal/ior.go +++ b/internal/ior.go @@ -3,6 +3,7 @@ package internal import "C" import ( + "context" "fmt" "os" "os/signal" @@ -78,9 +79,11 @@ func Run(flags flags.Flags) { loop := newEventLoop(flags) + ctx, cancel := context.WithCancel(context.Background()) c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) go func() { + defer cancel() <-c fmt.Println(loop.stats()) if flags.PprofEnable { @@ -88,10 +91,8 @@ func Run(flags flags.Flags) { pprof.StopCPUProfile() pprof.WriteHeapProfile(memProfile) } - loop.stop() - fmt.Println("Good bye... (unloading BPF tracepoints will take a few seconds...)") - os.Exit(0) }() - loop.run(ch) + loop.run(ctx, ch) + fmt.Println("Good bye... (unloading BPF tracepoints will take a few seconds...)") } |
