1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/pkg/command/execution.go

33 lines
704 B
Go
Raw Normal View History

package command
import (
"github.com/SAP/jenkins-library/pkg/log"
"os/exec"
"sync"
)
2022-11-08 09:47:38 +02:00
// errCopyStdout and errCopyStderr are filled after the command execution after Wait() terminates
type execution struct {
cmd *exec.Cmd
wg sync.WaitGroup
errCopyStdout error
errCopyStderr error
ul *log.URLLogger
}
func (execution *execution) Kill() error {
return execution.cmd.Process.Kill()
}
func (execution *execution) Wait() error {
execution.wg.Wait()
execution.ul.WriteURLsLogToJSON()
return execution.cmd.Wait()
}
// Execution references a background process which is started by RunExecutableInBackground
type Execution interface {
Kill() error
Wait() error
}