process

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(raw json.RawMessage) (interface{}, error)

Exec runs a command synchronously and returns its output.

func Stream

func Stream(raw json.RawMessage, conn Conn) (interface{}, error)

Stream runs a command and streams stdout/stderr as notifications, then returns the exit code.

Types

type Conn

type Conn interface {
	io.Writer
}

Conn abstracts the framed connection for sending notifications.

type ExecParams

type ExecParams struct {
	Command string            `json:"command"`
	Env     map[string]string `json:"env,omitempty"`
	Timeout int               `json:"timeout,omitempty"`
	Cwd     string            `json:"cwd,omitempty"`
}

ExecParams is the params for process.exec.

type ExecResult

type ExecResult struct {
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	ExitCode int    `json:"exit_code"`
}

ExecResult is the result of process.exec.

type Manager

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

Manager tracks spawned processes.

func NewManager

func NewManager() *Manager

NewManager returns a new process manager.

func (*Manager) Cleanup

func (m *Manager) Cleanup()

Cleanup kills all spawned process groups.

func (*Manager) Signal

func (m *Manager) Signal(raw json.RawMessage) (interface{}, error)

Signal sends a signal to a spawned process.

func (*Manager) Spawn

func (m *Manager) Spawn(raw json.RawMessage, conn Conn) (interface{}, error)

Spawn starts a process in the background and streams output as notifications.

func (*Manager) WriteStdin

func (m *Manager) WriteStdin(raw json.RawMessage) (interface{}, error)

WriteStdin writes data to a spawned process's stdin.

type PtyManager

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

PtyManager tracks PTY processes.

func NewPtyManager

func NewPtyManager() *PtyManager

NewPtyManager returns a new PTY manager.

func (*PtyManager) Cleanup

func (m *PtyManager) Cleanup()

Cleanup kills all PTY process groups and closes their master fds.

func (*PtyManager) HasPty

func (m *PtyManager) HasPty(pid int) bool

HasPty checks if a PID belongs to a PTY process.

func (*PtyManager) Resize

func (m *PtyManager) Resize(raw json.RawMessage) (interface{}, error)

Resize changes the terminal size of a PTY process.

func (*PtyManager) StartPty

func (m *PtyManager) StartPty(raw json.RawMessage, conn io.ReadWriter) (interface{}, error)

StartPty starts a command with a PTY and streams output as binary frames.

func (*PtyManager) WritePtyInput

func (m *PtyManager) WritePtyInput(pid int, data []byte) error

WritePtyInput writes binary data to a PTY's master fd.

type PtyParams

type PtyParams struct {
	Command string            `json:"command,omitempty"`
	Cols    uint16            `json:"cols,omitempty"`
	Rows    uint16            `json:"rows,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	Cwd     string            `json:"cwd,omitempty"`
}

PtyParams is the params for process.pty.

type PtyProcess

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

PtyProcess tracks a running PTY process.

type ResizeParams

type ResizeParams struct {
	PID  int    `json:"pid"`
	Cols uint16 `json:"cols"`
	Rows uint16 `json:"rows"`
}

ResizeParams is the params for process.resize.

type SignalParams

type SignalParams struct {
	PID    int    `json:"pid"`
	Signal string `json:"signal"`
}

SignalParams is the params for process.signal.

type SpawnParams

type SpawnParams struct {
	Command string            `json:"command"`
	Env     map[string]string `json:"env,omitempty"`
	Cwd     string            `json:"cwd,omitempty"`
}

SpawnParams is the params for process.spawn.

type SpawnedProcess

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

SpawnedProcess tracks a running spawned process.

type StdinParams

type StdinParams struct {
	PID  int    `json:"pid"`
	Data string `json:"data"` // base64
}

StdinParams is the params for process.stdin.

type StreamParams

type StreamParams struct {
	Command string            `json:"command"`
	Env     map[string]string `json:"env,omitempty"`
	Timeout int               `json:"timeout,omitempty"`
	Cwd     string            `json:"cwd,omitempty"`
}

StreamParams is the params for process.stream.

Jump to

Keyboard shortcuts

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