github.com/jaylevin/jenkins-library@v1.230.4/pkg/command/execution.go (about)

     1  package command
     2  
     3  import (
     4  	"os/exec"
     5  	"sync"
     6  )
     7  
     8  //errCopyStdout and errCopyStderr are filled after the command execution after Wait() terminates
     9  type execution struct {
    10  	cmd           *exec.Cmd
    11  	wg            sync.WaitGroup
    12  	errCopyStdout error
    13  	errCopyStderr error
    14  }
    15  
    16  func (execution *execution) Kill() error {
    17  	return execution.cmd.Process.Kill()
    18  }
    19  
    20  func (execution *execution) Wait() error {
    21  	execution.wg.Wait()
    22  	return execution.cmd.Wait()
    23  }
    24  
    25  // Execution references a background process which is started by RunExecutableInBackground
    26  type Execution interface {
    27  	Kill() error
    28  	Wait() error
    29  }