We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fac9639 commit 2ec280dCopy full SHA for 2ec280d
cmd/naisdevice-systray/main.go
@@ -56,6 +56,9 @@ func main() {
56
}
57
58
func run(ctx context.Context, notifier notify.Notifier) error {
59
+ ctx, cancel := context.WithCancel(ctx)
60
+ defer cancel()
61
+
62
otelCancel, err := otel.SetupOTelSDK(ctx, "naisdevice-systray", log)
63
if err != nil {
64
log.WithError(err).Warnf("setup OTel SDK")
@@ -104,7 +107,13 @@ func run(ctx context.Context, notifier notify.Notifier) error {
104
107
span.RecordError(err)
105
108
return fmt.Errorf("spawning naisdevice-agent: %w", err)
106
109
- defer command.Wait()
110
+ defer func() {
111
+ cancel()
112
+ err := command.Wait()
113
+ if err != nil {
114
+ log.Errorf("naisdevice-agent exited with error: %v", err)
115
+ }
116
+ }()
117
} else {
118
span.AddEvent("agent.reuse")
119
err := conn.Close()
0 commit comments