Here's my code (writeFromProcessToFileWithMax is an internal function, and is working properly):
// Go routines for non-blocking reading of stdout and stderr and writing to files
g := new(errgroup.Group)
// Read stdout in goroutine.
g.Go(func() error {
err = writeFromProcessToFileWithMax(stdoutScanner, stdoutFileWriter, maxStdoutFileLengthInGB)
if err != nil {
log.Error().Err(err).Msgf("Error writing to stdout file: %s", stdoutFilename)
return err
}
return nil
})
// Read stderr in goroutine.
g.Go(func() error {
err = writeFromProcessToFileWithMax(stderrScanner, stderrFileWriter, maxStderrFileLengthInGB)
if err != nil {
log.Error().Err(err).Msgf("Error writing to stderr file: %s", stderrFilename)
return err
}
return nil
})
// Wait the command in a goroutine.
g.Go(func() error {
return cmd.Wait()
})
// Starting the command
if err = cmd.Start(); err != nil {
log.Error().Err(err).Msg("Error starting command")
return err
}
// Waiting until errorGroups groups are done
if err = g.Wait(); err != nil {
log.Error().Err(err).Msg("Error during running of the command")
}
When I run it, I get the following Error = Error during running of the command error="exec: not started". But everything works properly.
Will the come back to bite me or should I suppress?