}
// Wait waits for the Process to exit or stop, and then returns a
-// Waitmsg describing its status and an error, if any.
+// ProcessState describing its status and an error, if any.
func (p *Process) Wait() (ps *ProcessState, err error) {
var waitmsg syscall.Waitmsg
ps = &ProcessState{
pid: waitmsg.Pid,
- status: waitmsg,
+ status: &waitmsg,
}
return ps, nil
}
// ProcessState stores information about process as reported by Wait.
type ProcessState struct {
- pid int // The process's id.
- status syscall.Waitmsg // System-dependent status info.
+ pid int // The process's id.
+ status *syscall.Waitmsg // System-dependent status info.
}
// Pid returns the process id of the exited process.
// the process. Convert it to the appropriate underlying
// type, such as *syscall.Waitmsg on Plan 9, to access its contents.
func (p *ProcessState) Sys() interface{} {
- return &p.status
+ return p.status
}
// SysUsage returns system-dependent resource usage information about
// the exited process. Convert it to the appropriate underlying
-// type, such as *syscall.Waitmsg on Unix, to access its contents.
+// type, such as *syscall.Waitmsg on Plan 9, to access its contents.
func (p *ProcessState) SysUsage() interface{} {
- return &p.status
+ return p.status
}
// UserTime returns the user CPU time of the exited process and its children.
// ProcessState stores information about process as reported by Wait.
type ProcessState struct {
- pid int // The process's id.
- status *syscall.WaitStatus // System-dependent status info.
+ pid int // The process's id.
+ status syscall.WaitStatus // System-dependent status info.
rusage *syscall.Rusage
}
// Sys returns system-dependent exit information about
// the process. Convert it to the appropriate underlying
-// type, such as *syscall.WaitStatus on Unix, to access its contents.
+// type, such as syscall.WaitStatus on Unix, to access its contents.
func (p *ProcessState) Sys() interface{} {
return p.status
}
if p == nil {
return "<nil>"
}
- status := p.Sys().(*syscall.WaitStatus)
+ status := p.Sys().(syscall.WaitStatus)
res := ""
switch {
case status.Exited():
return nil, NewSyscallError("GetExitCodeProcess", e)
}
p.done = true
- return &ProcessState{p.Pid, &syscall.WaitStatus{Status: s, ExitCode: ec}, new(syscall.Rusage)}, nil
+ return &ProcessState{p.Pid, syscall.WaitStatus{Status: s, ExitCode: ec}, new(syscall.Rusage)}, nil
}
// Signal sends a signal to the Process.