Skip to content

Commit

Permalink
fix: fixes segfault when process is TERMed
Browse files Browse the repository at this point in the history
Fixes #334

This change prevents agent from having a segmentation fault when
it receives a TERM or INT signal.
  • Loading branch information
dekobon committed Jun 6, 2023
1 parent 5974615 commit 0dcd66d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ func handleSignals(
)
log.Debugf("Sending agent stopped event: %v", stopCmd)

if err := cmder.Send(ctx, client.MessageFromCommand(stopCmd)); err != nil {
if cmder == nil {
log.Warn("Command channel not configured. Skipping sending AgentStopped event")
} else if err := cmder.Send(ctx, client.MessageFromCommand(stopCmd)); err != nil {
log.Errorf("Error sending AgentStopped event to command channel: %v", err)
}

Expand Down

0 comments on commit 0dcd66d

Please sign in to comment.