Skip to content

Commit

Permalink
fix: fixes segfault when process is TERMed (#335)
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 authored Jun 8, 2023
1 parent e8d45a3 commit a0d027a
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 a0d027a

Please sign in to comment.