1
0
mirror of https://github.com/golang/go synced 2024-11-24 22:00:09 -07:00

os: make the system info a value not a pointer on unix

fix a couple of other minor related details.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5690071
This commit is contained in:
Rob Pike 2012-02-23 07:51:49 +11:00
parent bb4a490928
commit 880cda557a
4 changed files with 13 additions and 13 deletions

View File

@ -66,7 +66,7 @@ func (p *Process) Kill() error {
} }
// Wait waits for the Process to exit or stop, and then returns a // 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) { func (p *Process) Wait() (ps *ProcessState, err error) {
var waitmsg syscall.Waitmsg var waitmsg syscall.Waitmsg
@ -89,7 +89,7 @@ func (p *Process) Wait() (ps *ProcessState, err error) {
ps = &ProcessState{ ps = &ProcessState{
pid: waitmsg.Pid, pid: waitmsg.Pid,
status: waitmsg, status: &waitmsg,
} }
return ps, nil return ps, nil
} }
@ -111,7 +111,7 @@ func findProcess(pid int) (p *Process, err error) {
// ProcessState stores information about process as reported by Wait. // ProcessState stores information about process as reported by Wait.
type ProcessState struct { type ProcessState struct {
pid int // The process's id. pid int // The process's id.
status syscall.Waitmsg // System-dependent status info. status *syscall.Waitmsg // System-dependent status info.
} }
// Pid returns the process id of the exited process. // Pid returns the process id of the exited process.
@ -134,14 +134,14 @@ func (p *ProcessState) Success() bool {
// the process. Convert it to the appropriate underlying // the process. Convert it to the appropriate underlying
// type, such as *syscall.Waitmsg on Plan 9, to access its contents. // type, such as *syscall.Waitmsg on Plan 9, to access its contents.
func (p *ProcessState) Sys() interface{} { func (p *ProcessState) Sys() interface{} {
return &p.status return p.status
} }
// SysUsage returns system-dependent resource usage information about // SysUsage returns system-dependent resource usage information about
// the exited process. Convert it to the appropriate underlying // 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{} { func (p *ProcessState) SysUsage() interface{} {
return &p.status return p.status
} }
// UserTime returns the user CPU time of the exited process and its children. // UserTime returns the user CPU time of the exited process and its children.

View File

@ -45,7 +45,7 @@ func (p *Process) Kill() error {
// ProcessState stores information about process as reported by Wait. // ProcessState stores information about process as reported by Wait.
type ProcessState struct { type ProcessState struct {
pid int // The process's id. pid int // The process's id.
status *syscall.WaitStatus // System-dependent status info. status syscall.WaitStatus // System-dependent status info.
rusage *syscall.Rusage rusage *syscall.Rusage
} }
@ -67,7 +67,7 @@ func (p *ProcessState) Success() bool {
// Sys returns system-dependent exit information about // Sys returns system-dependent exit information about
// the process. Convert it to the appropriate underlying // 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{} { func (p *ProcessState) Sys() interface{} {
return p.status return p.status
} }
@ -110,7 +110,7 @@ func (p *ProcessState) String() string {
if p == nil { if p == nil {
return "<nil>" return "<nil>"
} }
status := p.Sys().(*syscall.WaitStatus) status := p.Sys().(syscall.WaitStatus)
res := "" res := ""
switch { switch {
case status.Exited(): case status.Exited():

View File

@ -30,7 +30,7 @@ func (p *Process) Wait() (ps *ProcessState, err error) {
} }
ps = &ProcessState{ ps = &ProcessState{
pid: pid1, pid: pid1,
status: &status, status: status,
rusage: &rusage, rusage: &rusage,
} }
return ps, nil return ps, nil

View File

@ -30,7 +30,7 @@ func (p *Process) Wait() (ps *ProcessState, err error) {
return nil, NewSyscallError("GetExitCodeProcess", e) return nil, NewSyscallError("GetExitCodeProcess", e)
} }
p.done = true 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. // Signal sends a signal to the Process.