diff --git a/cshared.go b/cshared.go index 35373c0..3c5a2b2 100644 --- a/cshared.go +++ b/cshared.go @@ -201,8 +201,16 @@ func prepareInputCollector() (err error) { go func(theChannel chan<- Message) { defer theInputLock.Unlock() + for { + select { + case <-runCtx.Done(): + log.Printf("goroutine will be stopping: name=%q\n", theName) + return + default: + err = theInput.Collect(runCtx, theChannel) + } + } - err := theInput.Collect(runCtx, theChannel) if err != nil { fmt.Fprintf(os.Stderr, "collect error: %s\n", err.Error())