Skip to content

Conversation

pixel365
Copy link
Contributor

This PR fixes an issue where the deferred stop() (from signal.NotifyContext) would not be executed if logger.L().Fatal(...) is called due to a command failure. Since Fatal internally invokes os.Exit(1), any deferred functions — including stop() — are skipped.

To address this, an explicit call to stop() is added before Fatal to ensure that the context is properly cancelled. This guarantees that any goroutines waiting on ctx.Done() can proceed with cleanup or shutdown logic.

Changes

  • Added stop() before logger.L().Fatal(...) in main.

Signed-off-by: Ruslan Semagin <pixel.365.24@gmail.com>
@matthyx matthyx moved this to Needs Reviewer in KS PRs tracking May 16, 2025
Copy link
Contributor

@matthyx matthyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @pixel365 !

@matthyx matthyx merged commit b67b9f3 into kubescape:master May 16, 2025
4 checks passed
@pixel365 pixel365 deleted the cancel branch May 17, 2025 03:11
@matthyx matthyx moved this from Needs Reviewer to To Archive in KS PRs tracking May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants