github.com/secure-build/gitlab-runner@v12.5.0+incompatible/executors/custom/command/commander.go (about)

     1  package command
     2  
     3  import (
     4  	"os"
     5  	"os/exec"
     6  )
     7  
     8  type commander interface {
     9  	Start() error
    10  	Wait() error
    11  	Process() *os.Process
    12  }
    13  
    14  type cmd struct {
    15  	internal *exec.Cmd
    16  }
    17  
    18  var newCmd = func(executable string, args []string, options CreateOptions) commander {
    19  	c := exec.Command(executable, args...)
    20  	c.Dir = options.Dir
    21  	c.Env = options.Env
    22  	c.Stdin = nil
    23  	c.Stdout = options.Stdout
    24  	c.Stderr = options.Stderr
    25  
    26  	return &cmd{internal: c}
    27  }
    28  
    29  func (c *cmd) Start() error {
    30  	return c.internal.Start()
    31  }
    32  
    33  func (c *cmd) Wait() error {
    34  	return c.internal.Wait()
    35  }
    36  
    37  func (c *cmd) Process() *os.Process {
    38  	return c.internal.Process
    39  }