libsandbox

package module
v0.0.0-...-9414438 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2016 License: Apache-2.0 Imports: 14 Imported by: 2

README

Go Report Card Coverage Status GoDoc

#Sandbox

Sandbox for online judge.

##Install

command

$ go get github.com/ggaaooppeenngg/libsandbox
$ go install github.com/ggaaooppeenngg/libsandbox/...

###Usage

// compile before running and specify limit
sandbox --lang=c -c -s src/main.c -b bin/main --memory=10000 --time=1000 --input=judge/input --output==judge/output
// running with compiled binary file
sandbox --lang=c -b bin/main -i judge/input -o judge/output

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TICK     time.Duration
	PAGESIZE int64
)
View Source
var (
	OutOfTimeError   = errors.New("out of time")
	OutOfMemoryError = errors.New("out of memory")
)

Functions

func CpuTime

func CpuTime(pid int) int64

CpuTime returns cpu usage of process in second. TODO: dont panic error

func GetResourceUsage

func GetResourceUsage(pid int) (ok bool, vm int64, rss int64,
	rt int64, ct int64)

func RssSize

func RssSize(pid int) int64

RssSize returns process resident memory, but doesn't include swapped out memory

func RunningTime

func RunningTime(pid int) int64

Running returns process total running time from the start

func RuntimeError

func RuntimeError(signal os.Signal) error

func VirtualMemory

func VirtualMemory(pid int) int64

VirtualMemory returns process virtual memory

Types

type Config

type Config struct {
	Args   []string
	Input  io.Reader
	Memory int64
	Time   int64
}

sandbox config

func (Config) Validate

func (conf Config) Validate() error

type Sandbox

type Sandbox interface {
	Run() (output []byte, err error)
	Time() int64
	Memory() int64
}

func NewStdSandbox

func NewStdSandbox(conf Config) (Sandbox, error)

type StdSandbox

type StdSandbox struct {
	Bin         string    // binary path
	Args        []string  // arguments
	Input       io.Reader // standard input
	TimeLimit   int64     // time limit in ms
	MemoryLimit int64     // memory limit in kb
	// contains filtered or unexported fields
}

func (*StdSandbox) Memory

func (s *StdSandbox) Memory() int64

func (*StdSandbox) Run

func (s *StdSandbox) Run() ([]byte, error)

func (*StdSandbox) Time

func (s *StdSandbox) Time() int64

Directories

Path Synopsis
sandbox is command line interface for the Sandbox without docker wrapped.
sandbox is command line interface for the Sandbox without docker wrapped.

Jump to

Keyboard shortcuts

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