Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init()
Init should be called at the point that forks should begin to execute. This should likely be very early in main() or within init() (to skip main entirely)
At the point where this is called, either:
We are identified as a fork, we execute that function, and exit. or, we are not identified as afork and simply return.
func Register ¶
func Register(f *Function)
Register records a Fork in the internal fork map. Register must be called before Fork on agiven function (func init() is a common place)
func RegisterFunc ¶
func RegisterFunc(n string, fn interface{})
RegisterFunc records a function as a fork in the internal fork map. Register must be called before Fork on agiven function (func init() is a common place)
Types ¶
type Function ¶
type Function struct { // SysProcAttr holds optional, operating system-sepcific attributes. SysProcAttr *syscall.SysProcAttr // Process will hold the os.Process once the Fork has been Run(). Process *os.Process // ProcessState will hold the os.ProcessState after Wait() has been called. ProcessState *os.ProcessState // Name is the string we use to identify this func Name string // Where to send stdout (default: os.Stdout) Stdout *os.File // Where to send stderr (default: os.Stderr) Stderr *os.File // Where to get stdin (default: os.Stdin) Stdin *os.File // contains filtered or unexported fields }
A Function struct describes a fork process. Usually this is only used internally, but if you want a bit more control of the sub-process, say, to assing new namespaces to the child, this will provide it.
A Fork is a wrapper around an `exec.Cmd` with some of parts the data structure exposed (that we don't need to control directly).
func NewFork ¶
NewFork createas and initializes a Fork A Fork object can be manipluated to control how a process is launched. E.g. you can set new namespaces in the SysProcAttr property...
or, you can set custom args with the (optional) variatic args aparameters. If you set args, the first should be the program name (Args[0]), which may Which may or may not match the executable.
If no args are specified, args is set to []string{os.Args[0]}