exec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cmdStr string) (result string)

Run creates and runs a process and returns the result as a string. Equivalent to: Proc.StartProc() -> Proc.Result()

Types

type Proc

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

Proc stores process info

func RunProc

func RunProc(cmdStr string) *Proc

RunProc creates, runs, and waits for a process to complete and return *Proc with result info. This can be followed by Proc.Result() to access to string value of the returned by process.

func StartProc

func StartProc(cmdStr string) *Proc

StartProc creates a *Proc and starts an OS process but does not wait for it to complete.

func (*Proc) Command

func (p *Proc) Command() *osexec.Cmd

Command returns the os/exec.Cmd that started the process

func (*Proc) Err

func (p *Proc) Err() error

Err returns any execution error

func (*Proc) ExitCode

func (p *Proc) ExitCode() int

ExitCode returns process exit code

func (*Proc) Exited

func (p *Proc) Exited() bool

Exited returns true if process exits ok

func (*Proc) ID

func (p *Proc) ID() int

ID returns process id

func (*Proc) IsSuccess

func (p *Proc) IsSuccess() bool

IsSuccess returns true if proc exit ok

func (*Proc) Kill

func (p *Proc) Kill() *Proc

Kill halts the process

func (*Proc) Out

func (p *Proc) Out() io.Reader

Out waits for cmd result and surfaces the result from both stdout and stderr in an io.Reader that can be streamed. Must be called after after Proc.StartProc, Proc.RunProc

func (*Proc) Peek

func (p *Proc) Peek() *Proc

Peek attempts to read process state information

func (*Proc) Result

func (p *Proc) Result() string

Result waits and copies the result of the combined stdout and stderr and returns its result as a string. Must be called after Proc.StartProc Proc.RunProc() or Proc.Run().

func (*Proc) StdErr

func (p *Proc) StdErr() io.Reader

StdErr is an io.Reader pipe for standard error Must be streamed before Proc.Wait().

func (*Proc) StdOut

func (p *Proc) StdOut() io.Reader

StdOut is a io.Reader pipe for standard out Must be streamed before Proc.Wait()

func (*Proc) SysTime

func (p *Proc) SysTime() time.Duration

SysTime returns proc system cpu time

func (*Proc) UserTime

func (p *Proc) UserTime() time.Duration

UserTime returns proc user cpu time

func (*Proc) Wait

func (p *Proc) Wait() *Proc

Wait waits for a process started with Proc.StartProc to complete (in a separate goroutine). Once process completes, Wait cleans up resources. Must be called after Proc.StartProc()

Jump to

Keyboard shortcuts

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