diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-08-03 16:54:30 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-08-03 16:54:30 +0200 |
commit | 28592ee1ea1f5cdffcf85472f9de0285d928cf12 (patch) | |
tree | 32944e18b23f7fe4a0818a694aa2a6dfb1835463 /src/pkg/os/exec_plan9.go | |
parent | e836bee4716dc0d4d913537ad3ad1925a7ac32d0 (diff) | |
download | golang-upstream/59.tar.gz |
Imported Upstream version 59upstream/59
Diffstat (limited to 'src/pkg/os/exec_plan9.go')
-rw-r--r-- | src/pkg/os/exec_plan9.go | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/pkg/os/exec_plan9.go b/src/pkg/os/exec_plan9.go index 11874aba6..2590dd67d 100644 --- a/src/pkg/os/exec_plan9.go +++ b/src/pkg/os/exec_plan9.go @@ -15,6 +15,7 @@ func StartProcess(name string, argv []string, attr *ProcAttr) (p *Process, err E sysattr := &syscall.ProcAttr{ Dir: attr.Dir, Env: attr.Env, + Sys: attr.Sys, } // Create array of integer (system) fds. @@ -37,6 +38,17 @@ func StartProcess(name string, argv []string, attr *ProcAttr) (p *Process, err E return newProcess(pid, h), nil } +// Kill causes the Process to exit immediately. +func (p *Process) Kill() Error { + f, e := OpenFile("/proc/"+itoa(p.Pid)+"/ctl", O_WRONLY, 0) + if iserror(e) { + return NewSyscallError("kill", e) + } + defer f.Close() + _, e = f.Write([]byte("kill")) + return e +} + // Exec replaces the current process with an execution of the // named binary, with arguments argv and environment envv. // If successful, Exec never returns. If it fails, it returns an Error. @@ -51,7 +63,9 @@ func Exec(name string, argv []string, envv []string) Error { } // Waitmsg stores the information about an exited process as reported by Wait. -type Waitmsg syscall.Waitmsg +type Waitmsg struct { + syscall.Waitmsg +} // Wait waits for the Process to exit or stop, and then returns a // Waitmsg describing its status and an Error, if any. The options @@ -75,7 +89,7 @@ func (p *Process) Wait(options int) (w *Waitmsg, err Error) { } } - return (*Waitmsg)(&waitmsg), nil + return &Waitmsg{waitmsg}, nil } // Wait waits for process pid to exit or stop, and then returns a @@ -109,6 +123,9 @@ func FindProcess(pid int) (p *Process, err Error) { return newProcess(pid, 0), nil } -func (w Waitmsg) String() string { +func (w *Waitmsg) String() string { + if w == nil { + return "<nil>" + } return "exit status: " + w.Msg } |