proc

package
v0.0.0-...-5574eb5 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Atomic

type Atomic[T any] struct {
	Locker sync.Mutex
	// contains filtered or unexported fields
}

Atomic protect a val Type T with a mutex

func (*Atomic[T]) Load

func (v *Atomic[T]) Load() T

func (*Atomic[T]) Store

func (v *Atomic[T]) Store(val T)

type Channel

type Channel[T any] struct {
	// contains filtered or unexported fields
}

Channel is channel that you can tell if it closed

func MakeChannel

func MakeChannel[T any](buffer int) *Channel[T]

func (*Channel[T]) Close

func (c *Channel[T]) Close()

func (*Channel[T]) Closed

func (c *Channel[T]) Closed() bool

func (*Channel[T]) Recv

func (c *Channel[T]) Recv() (T, bool)

func (*Channel[T]) Send

func (c *Channel[T]) Send(v T)

func (*Channel[T]) TryRecv

func (c *Channel[T]) TryRecv() (T, bool)

func (*Channel[T]) TrySend

func (c *Channel[T]) TrySend(v T) bool

type Option

type Option func(*Options)

Option apply option into *Options

func WithCommand

func WithCommand(name string, args ...string) Option

func WithEnv

func WithEnv(env map[string]string) Option

func WithMaxWaitTime

func WithMaxWaitTime(t time.Duration) Option

func WithStderr

func WithStderr() Option

func WithStdin

func WithStdin() Option

func WithStdout

func WithStdout() Option

func WithWorkDir

func WithWorkDir(dir string) Option

type Options

type Options struct {
	Name    string
	Args    []string
	WorkDir string
	Env     []string

	// create stdin pipe
	Stdin bool
	// create stdout pipe
	Stdout bool
	// create stderr pipe
	Stderr bool

	// max wait time before stop the process
	MaxWaitTime time.Duration
}

type Proc

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

Proc represent a child process of dontstarve

func NewProc

func NewProc(ctx context.Context, procOptions ...Option) (*Proc, error)

NewProc return a new Process

func (*Proc) CMDLine

func (p *Proc) CMDLine() []string

CMDLine return cmd line args for the process

func (*Proc) CPUPercent

func (p *Proc) CPUPercent() (float64, error)

CPUPercent returns how many percent of the CPU time this process uses

func (*Proc) CloseSig

func (p *Proc) CloseSig(sig syscall.Signal) error

CloseSig close the process with signal

func (*Proc) CreatedAt

func (p *Proc) CreatedAt() (time.Time, error)

CreatedAt return the time at process creating

func (*Proc) Cwd

func (p *Proc) Cwd() (string, error)

Cwd returns current working directory of the process.

func (*Proc) Exe

func (p *Proc) Exe() (string, error)

Exe returns executable path of the process.

func (*Proc) ExitCode

func (p *Proc) ExitCode() int

ExitCode returns the exit code of the exited process, or -1 if the process hasn't exited or was terminated by a signal.

func (*Proc) IOCounters

func (p *Proc) IOCounters() (*process.IOCountersStat, error)

IOCounters returns IO Counters.

func (*Proc) IsRunning

func (p *Proc) IsRunning() (bool, error)

IsRunning returns whether the process is still running or not.

func (*Proc) Kill

func (p *Proc) Kill() error

Kill causes the Process to exit immediately. Kill does not wait until the Process has actually exited

func (*Proc) MemoryInfo

func (p *Proc) MemoryInfo() (*process.MemoryInfoStat, error)

MemoryInfo returns generic process memory information, such as RSS and VMS.

func (*Proc) Name

func (p *Proc) Name() string

Name returns name of the process.

func (*Proc) NumConnections

func (p *Proc) NumConnections() (int, error)

NumConnections the number of Connections used by the process. This returns all kind of the connection. This means TCP, UDP or UNIX.

func (*Proc) NumFDs

func (p *Proc) NumFDs() (int32, error)

NumFDs returns the number of File Descriptors used by the process.

func (*Proc) NumThreads

func (p *Proc) NumThreads() (int32, error)

NumThreads returns the number of threads used by the process.

func (*Proc) PID

func (p *Proc) PID() int

PID returns the process id of the process.

func (*Proc) Signal

func (p *Proc) Signal(signal syscall.Signal) error

Signal sends a signal to the Process.

func (*Proc) Start

func (p *Proc) Start() error

Start starts the process but does not wait for it to complete.

func (*Proc) StderrPipe

func (p *Proc) StderrPipe(name string) *Stream

StderrPipe return a named stream pipe with stderr

func (*Proc) StdinPipe

func (p *Proc) StdinPipe(name string) *Stream

StdinPipe return a named stream pipe with stdin

func (*Proc) StdoutPipe

func (p *Proc) StdoutPipe(name string) *Stream

StdoutPipe return a named stream pipe with stdout

func (*Proc) Terminate

func (p *Proc) Terminate() error

Terminate closed the process with syscall.SIGTERM, should not call concurrently

func (*Proc) Wait

func (p *Proc) Wait() error

Wait waits for the process to exit and waits for any copying to stdin or copying from stdout or stderr to complete.

type Stream

type Stream = Channel[[]byte]

Jump to

Keyboard shortcuts

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