safeexec

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDisableCpuLimit

func WithDisableCpuLimit(m *Manager) error

func WithDisableMemoryPeak

func WithDisableMemoryPeak(m *Manager) error

Types

type Manager

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

func NewManager

func NewManager(path, executionPath, cgroupName string, options ...Option) (*Manager, error)

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, config ProcessConfig) (*Process, error)

func (*Manager) HasCPULimit

func (m *Manager) HasCPULimit() bool

func (*Manager) HasMemoryPeak

func (m *Manager) HasMemoryPeak() bool

type Option

type Option func(*Manager) error

func WithPidsLimit added in v0.2.2

func WithPidsLimit(limit int) Option

type Process

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

func (*Process) Release

func (p *Process) Release() error

Release releases all associatet resources with process.

func (*Process) Start

func (p *Process) Start() error

func (*Process) UpperDir

func (p *Process) UpperDir() string

func (*Process) UpperPath

func (p *Process) UpperPath(path string) string

func (*Process) Wait

func (p *Process) Wait() (Report, error)

type ProcessConfig

type ProcessConfig struct {
	TimeLimit   time.Duration
	MemoryLimit int64
	Stdin       io.Reader
	Stdout      io.Writer
	Stderr      io.Writer
	Layers      []string
	Environ     []string
	Workdir     string
	Command     []string
}

type Report

type Report struct {
	Time     time.Duration
	RealTime time.Duration
	Memory   int64
	ExitCode int
}

Jump to

Keyboard shortcuts

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