Documentation ¶
Index ¶
- func EnablePrivilege(token syscall.Token, privilege string) error
- func UTF16FromUTF16Ptr(str *uint16) (rt []uint16)
- type Cmd
- func (c *Cmd) CombinedOutput() ([]byte, error)
- func (c *Cmd) Output() ([]byte, error)
- func (c *Cmd) Run() error
- func (c *Cmd) Start() error
- func (c *Cmd) StderrPipe() (io.ReadCloser, error)
- func (c *Cmd) StdinPipe() (io.WriteCloser, error)
- func (c *Cmd) StdoutPipe() (io.ReadCloser, error)
- func (c *Cmd) Wait() error
- type DWord
- type Process
- type ProcessState
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UTF16FromUTF16Ptr ¶
Types ¶
type Cmd ¶
type Cmd struct { // Path is the path of the command to run. // // This is the only field that must be set to a non-zero // value. If Path is relative, it is evaluated relative // to Dir. Path string // Args holds command line arguments, including the command as Args[0]. // If the Args field is empty or nil, Run uses {Path}. // // In typical use, both Path and Args are set by calling Command. Args []string // Dir specifies the working directory of the command. // If Dir is the empty string, Run runs the command in the // calling process's current directory. Dir string // Stdin specifies the process's standard input. // If Stdin is nil, the process reads from the null device (os.DevNull). // If Stdin is an *os.File, the process's standard input is connected // directly to that file. // Otherwise, during the execution of the command a separate // goroutine reads from Stdin and delivers that data to the command // over a pipe. In this case, Wait does not complete until the goroutine // stops copying, either because it has reached the end of Stdin // (EOF or a read error) or because writing to the pipe returned an error. Stdin io.Reader // Stdout and Stderr specify the process's standard output and error. // // If either is nil, Run connects the corresponding file descriptor // to the null device (os.DevNull). // // If Stdout and Stderr are the same writer, at most one // goroutine at a time will call Write. Stdout io.Writer Stderr io.Writer // ExtraFiles specifies additional open files to be inherited by the // new process. It does not include standard input, standard output, or // standard error. If non-nil, entry i becomes file descriptor 3+i. // // BUG(rsc): On OS X 10.6, child processes may sometimes inherit unwanted fds. // https://golang.org/issue/2603 ExtraFiles []*os.File // SysProcAttr holds optional, operating system-specific attributes. // Run passes it to os.StartProcess as the os.ProcAttr's Sys field. SysProcAttr *syscall.SysProcAttr // Process is the underlying process, once started. Process *Process // ProcessState contains information about an exited process, // available after a call to Wait or Run. ProcessState *ProcessState Username string Domain string // contains filtered or unexported fields }
Cmd represents an external command being prepared or run.
A Cmd cannot be reused after calling its Run, Output or CombinedOutput methods.
func Command ¶
Command returns the Cmd struct to execute the named program with the given arguments.
It sets only the Path and Args in the returned structure.
If name contains no path separators, Command uses LookPath to resolve the path to a complete name if possible. Otherwise it uses name directly.
The returned Cmd's Args field is constructed from the command name followed by the elements of arg, so arg should not include the command name itself. For example, Command("echo", "hello")
func (*Cmd) CombinedOutput ¶
CombinedOutput runs the command and returns its combined standard output and standard error.
func (*Cmd) Output ¶
Output runs the command and returns its standard output. Any returned error will usually be of type *ExitError. If c.Stderr was nil, Output populates ExitError.Stderr.
func (*Cmd) Start ¶
Start starts the specified command but does not wait for it to complete.
The Wait method will return the exit code and release associated resources once the command exits.
func (*Cmd) StderrPipe ¶
func (c *Cmd) StderrPipe() (io.ReadCloser, error)
func (*Cmd) StdoutPipe ¶
func (c *Cmd) StdoutPipe() (io.ReadCloser, error)
type Process ¶
type Process struct { Pid int // contains filtered or unexported fields }
Process stores the information about a process created by StartProcess.
func (*Process) Wait ¶
func (p *Process) Wait() (ps *ProcessState, err error)
type ProcessState ¶
type ProcessState struct { Status syscall.WaitStatus // System-dependent status info. // contains filtered or unexported fields }
ProcessState stores information about a process, as reported by Wait.
func (*ProcessState) Pid ¶
func (p *ProcessState) Pid() int
Pid returns the process id of the exited process.
func (*ProcessState) String ¶
func (p *ProcessState) String() string
func (*ProcessState) Success ¶
func (p *ProcessState) Success() bool
func (*ProcessState) SysUsage ¶
func (p *ProcessState) SysUsage() *syscall.Rusage
Notes ¶
Bugs ¶
On OS X 10.6, child processes may sometimes inherit unwanted fds. https://golang.org/issue/2603