summaryrefslogtreecommitdiff
path: root/src/pkg/os/exec_plan9.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/os/exec_plan9.go')
-rw-r--r--src/pkg/os/exec_plan9.go23
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
}