shellexec

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGracefulKillWait = 400 * time.Millisecond

Variables

This section is empty.

Functions

func ExitCodeFromWaitErr

func ExitCodeFromWaitErr(err error) int

func RunSimpleCmdInPty

func RunSimpleCmdInPty(ecmd *exec.Cmd, termSize waveobj.TermSize) ([]byte, error)

Types

type CmdWrap

type CmdWrap struct {
	Cmd      *exec.Cmd
	WaitOnce *sync.Once
	WaitErr  error
	pty.Pty
}

func MakeCmdWrap added in v0.10.0

func MakeCmdWrap(cmd *exec.Cmd, cmdPty pty.Pty) CmdWrap

func (CmdWrap) ExitCode added in v0.10.0

func (cw CmdWrap) ExitCode() int

only valid once Wait() has returned (or you know Cmd is done)

func (CmdWrap) Kill

func (cw CmdWrap) Kill()

func (CmdWrap) KillGraceful

func (cw CmdWrap) KillGraceful(timeout time.Duration)

func (CmdWrap) SetSize

func (cw CmdWrap) SetSize(w int, h int) error

func (CmdWrap) Start

func (cw CmdWrap) Start() error

func (CmdWrap) StderrPipe

func (cw CmdWrap) StderrPipe() (io.ReadCloser, error)

func (CmdWrap) StdinPipe

func (cw CmdWrap) StdinPipe() (io.WriteCloser, error)

func (CmdWrap) StdoutPipe

func (cw CmdWrap) StdoutPipe() (io.ReadCloser, error)

func (CmdWrap) Wait

func (cw CmdWrap) Wait() error

type CommandOptsType

type CommandOptsType struct {
	Interactive bool              `json:"interactive,omitempty"`
	Login       bool              `json:"login,omitempty"`
	Cwd         string            `json:"cwd,omitempty"`
	Env         map[string]string `json:"env,omitempty"`
	ShellPath   string            `json:"shellPath,omitempty"`
	ShellOpts   []string          `json:"shellOpts,omitempty"`
}

type ConnInterface

type ConnInterface interface {
	Kill()
	KillGraceful(time.Duration)
	Wait() error
	Start() error
	ExitCode() int
	StdinPipe() (io.WriteCloser, error)
	StdoutPipe() (io.ReadCloser, error)
	StderrPipe() (io.ReadCloser, error)
	SetSize(w int, h int) error
	pty.Pty
}

type PipePty

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

func (*PipePty) Close

func (pp *PipePty) Close() error

func (*PipePty) Fd

func (pp *PipePty) Fd() uintptr

func (*PipePty) Name

func (pp *PipePty) Name() string

func (*PipePty) Read

func (pp *PipePty) Read(p []byte) (n int, err error)

func (*PipePty) Write

func (pp *PipePty) Write(p []byte) (n int, err error)

func (*PipePty) WriteString

func (pp *PipePty) WriteString(s string) (n int, err error)

type SessionWrap

type SessionWrap struct {
	Session  *ssh.Session
	StartCmd string
	Tty      pty.Tty
	WaitOnce *sync.Once
	WaitErr  error
	pty.Pty
}

func MakeSessionWrap added in v0.10.0

func MakeSessionWrap(session *ssh.Session, startCmd string, sessionPty pty.Pty) SessionWrap

func (SessionWrap) ExitCode added in v0.10.0

func (sw SessionWrap) ExitCode() int

func (SessionWrap) Kill

func (sw SessionWrap) Kill()

func (SessionWrap) KillGraceful

func (sw SessionWrap) KillGraceful(timeout time.Duration)

func (SessionWrap) SetSize

func (sw SessionWrap) SetSize(h int, w int) error

func (SessionWrap) Start

func (sw SessionWrap) Start() error

func (SessionWrap) StderrPipe

func (sw SessionWrap) StderrPipe() (io.ReadCloser, error)

func (SessionWrap) StdinPipe

func (sw SessionWrap) StdinPipe() (io.WriteCloser, error)

func (SessionWrap) StdoutPipe

func (sw SessionWrap) StdoutPipe() (io.ReadCloser, error)

func (SessionWrap) Wait

func (sw SessionWrap) Wait() error

type ShellProc

type ShellProc struct {
	ConnName  string
	Cmd       ConnInterface
	CloseOnce *sync.Once
	DoneCh    chan any // closed after proc.Wait() returns
	WaitErr   error    // WaitErr is synchronized by DoneCh (written before DoneCh is closed) and CloseOnce
}

func StartRemoteShellProc

func StartRemoteShellProc(termSize waveobj.TermSize, cmdStr string, cmdOpts CommandOptsType, conn *conncontroller.SSHConn) (*ShellProc, error)

func StartRemoteShellProcNoWsh added in v0.10.0

func StartRemoteShellProcNoWsh(termSize waveobj.TermSize, cmdStr string, cmdOpts CommandOptsType, conn *conncontroller.SSHConn) (*ShellProc, error)

func StartShellProc

func StartShellProc(termSize waveobj.TermSize, cmdStr string, cmdOpts CommandOptsType) (*ShellProc, error)

func StartWslShellProc added in v0.9.0

func StartWslShellProc(ctx context.Context, termSize waveobj.TermSize, cmdStr string, cmdOpts CommandOptsType, conn *wsl.WslConn) (*ShellProc, error)

func (*ShellProc) Close

func (sp *ShellProc) Close()

func (*ShellProc) SetWaitErrorAndSignalDone

func (sp *ShellProc) SetWaitErrorAndSignalDone(waitErr error)

func (*ShellProc) Wait

func (sp *ShellProc) Wait() error

func (*ShellProc) WaitNB

func (sp *ShellProc) WaitNB() (bool, error)

returns (done, waitError)

type WslCmdWrap added in v0.9.0

type WslCmdWrap struct {
	*wsl.WslCmd
	Tty pty.Tty
	pty.Pty
}

func (WslCmdWrap) Kill added in v0.9.0

func (wcw WslCmdWrap) Kill()

func (WslCmdWrap) KillGraceful added in v0.9.0

func (wcw WslCmdWrap) KillGraceful(timeout time.Duration)

func (WslCmdWrap) SetSize added in v0.9.0

func (wcw WslCmdWrap) SetSize(w int, h int) error

*

  • SetSize does nothing for WslCmdWrap as there
  • is no pty to manage.

*

Jump to

Keyboard shortcuts

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