cmd

package
Version: v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package cmd provides a more domain-specific layer over exec.Cmd.

Index

Constants

View Source
const (
	// Shell will have the command line passed to its `-c` option.
	Shell = "/bin/bash"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(shellCmd string) (cmd *Cmd, out <-chan []byte, err error)

NewCommand returns a Cmd with IO configured, but not started.

func (*Cmd) StartWithStdin

func (c *Cmd) StartWithStdin(input []byte) (err error)

Start the process, write input to stdin, then close stdin.

func (*Cmd) Terminate

func (c *Cmd) Terminate() (err error)

Terminate the process with SIGTERM. TODO: follow up with SIGKILL if still running.

func (*Cmd) WaitChan

func (cmd *Cmd) WaitChan() <-chan WaitResult

WaitChan starts a goroutine to wait for the command to exit, and returns a channel over which will be sent the WaitResult, containing either the exit status (0 for success) or a non-exit error, e.g. IO error.

type WaitResult

type WaitResult struct {
	Status int
	Err    error
}

WaitResult is sent to the channel returned by WaitChan(). It indicates the exit status, or a non-exit-status error e.g. IO error. In the case of a non-exit-status, Status is -1

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL