mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 15:50:15 -08:00
fix: prevent graceful shutdown message on normal exit (#9244)
This commit is contained in:
@@ -42,8 +42,7 @@ func run() error {
|
||||
}
|
||||
|
||||
// Set up signal handling for graceful shutdown
|
||||
ctx, stop := commands.NotifyContext(context.Background())
|
||||
defer stop()
|
||||
ctx := commands.NotifyContext(context.Background())
|
||||
|
||||
app := commands.NewApp()
|
||||
return app.ExecuteContext(ctx)
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
// When a signal is received, Trivy will attempt to gracefully shut down by canceling
|
||||
// the context and waiting for all operations to complete. If users want to force an
|
||||
// immediate exit, they can send a second SIGINT or SIGTERM signal.
|
||||
func NotifyContext(parent context.Context) (context.Context, context.CancelFunc) {
|
||||
func NotifyContext(parent context.Context) context.Context {
|
||||
ctx, stop := signal.NotifyContext(parent, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
// Start a goroutine to handle cleanup when context is done
|
||||
@@ -33,5 +33,5 @@ func NotifyContext(parent context.Context) (context.Context, context.CancelFunc)
|
||||
stop()
|
||||
}()
|
||||
|
||||
return ctx, stop
|
||||
return ctx
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user