system

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2017 License: MPL-2.0 Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package system implements cross-platform abstractions for user-management access-control and sub-process execution geared at executing sub-process with best-effort sandboxing.

The system package provides the following platform specific types and methods.

 system.User
 system.User.Remove()
 system.Group
 system.Process
 system.Process.Wait() bool
 system.Process.Kill()
 system.SetSize(columns, rows uint16) error
	system.CreateUser(homeFolder string, groups []*Group) (*User, error)
 system.FindGroup(name string) (*Group, error)
	system.StartProcess(options ProcessOptions) (*Process, error)
	system.KillByOwner(user *User) error

Index

Constants

This section is empty.

Variables

View Source
var ErrUserGroupNotFound = errors.New("user group doesn't exist")

ErrUserGroupNotFound indicates that a given user-group doesn't exist.

Functions

func KillByOwner added in v0.0.8

func KillByOwner(user *User) error

KillByOwner will kill all process with the given owner.

func KillProcessTree added in v0.0.8

func KillProcessTree(root *Process) error

KillProcessTree will kill root and all of its descendents.

Types

type Process added in v0.0.8

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

Process is a representation of a system process.

func StartProcess added in v0.0.8

func StartProcess(options ProcessOptions) (*Process, error)

StartProcess starts a new process with given arguments, environment variables, and current working folder, running as given user.

Returns an human readable error explaining why the sub-process couldn't start if not successful.

func (*Process) Kill added in v0.0.8

func (p *Process) Kill()

Kill the process

func (*Process) SetSize added in v0.0.8

func (p *Process) SetSize(columns, rows uint16)

SetSize of the TTY, if running as TTY or do nothing.

func (*Process) Wait added in v0.0.8

func (p *Process) Wait() bool

Wait for process to terminate, returns true, if exited zero.

type ProcessOptions

type ProcessOptions struct {
	Arguments     []string          // Command and arguments, default to shell
	Environment   map[string]string // Environment variables
	WorkingFolder string            // Working directory, if not HOME
	Owner         *User             // User to run process as, nil to use current
	Stdin         io.ReadCloser     // Stream with stdin, or nil if nothing
	Stdout        io.WriteCloser    // Stream for stdout
	Stderr        io.WriteCloser    // Stream for stderr, or nil if using stdout
	TTY           bool              // Start as TTY, if supported, ignores stderr
}

ProcessOptions are the arguments given for StartProcess. This structure is platform independent.

Jump to

Keyboard shortcuts

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