diff --git a/linux/run.go b/linux/run.go index d969176..c9b5876 100644 --- a/linux/run.go +++ b/linux/run.go @@ -2,9 +2,11 @@ package linux import ( "bufio" + "bytes" "errors" "fmt" "golang.org/x/sys/unix" + "io" "os" "os/exec" "os/signal" @@ -192,7 +194,11 @@ func (cmd *LinuxCommand) Run() error { } exitInfo.HasSucceeded = false exitInfo.ExitCode = exitErr.ExitCode() - exitInfo.Error = exitErr.String() + var stdoutData bytes.Buffer + if _, err := io.Copy(&stdoutData, cmd.stdout); err != nil { + return err + } + exitInfo.Error = stdoutData.String() err := h.(func(data EventExitData) error)(*exitInfo) if err != nil { return fmt.Errorf("%s: %w", ErrRunningEvt.Error(), err) @@ -206,7 +212,11 @@ func (cmd *LinuxCommand) Run() error { } exitInfo.HasSucceeded = false exitInfo.ExitCode = exitErr.ExitCode() - exitInfo.Error = exitErr.String() + var stdoutData bytes.Buffer + if _, err := io.Copy(&stdoutData, cmd.stdout); err != nil { + return err + } + exitInfo.Error = stdoutData.String() err := h.(func(data EventExitData) error)(*exitInfo) if err != nil { return fmt.Errorf("%s: %w", ErrRunningEvt.Error(), err)