Skip to content

Commit

Permalink
main: Improve logging in signal handling loop
Browse files Browse the repository at this point in the history
Simplified the logging calls in `signalHandlerLoop()` and ensured that
any errors are logged correctly.

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed May 8, 2018
1 parent 075ad56 commit f8081ca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,16 @@ func (s *sandbox) listenToUdevEvents() {
// This loop is meant to be run inside a separate Go routine.
func (s *sandbox) signalHandlerLoop(sigCh chan os.Signal) {
for sig := range sigCh {
logger := agentLog.WithField("signal", sig)

switch sig {
case unix.SIGCHLD:
if err := s.subreaper.reap(); err != nil {
agentLog.Error(err)
logger.WithError(err).Error("failed to reap")
return
}
default:
agentLog.Infof("Unexpected signal %s, nothing to do...", sig.String())
logger.Info("ignoring unexpected signal")
}
}
}
Expand Down

0 comments on commit f8081ca

Please sign in to comment.