aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/os/exec_plan9.go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-09-16 15:47:21 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-09-16 15:47:21 +0000
commitadb0401dac41c81571722312d4586b2693f95aa6 (patch)
treeea2b52e3c258d6b6d9356977c683c7f72a4a5fd5 /libgo/go/os/exec_plan9.go
parent5548ca3540bccbc908a45942896d635ea5f1c23f (diff)
downloadgcc-adb0401dac41c81571722312d4586b2693f95aa6.zip
gcc-adb0401dac41c81571722312d4586b2693f95aa6.tar.gz
gcc-adb0401dac41c81571722312d4586b2693f95aa6.tar.bz2
Update Go library to r60.
From-SVN: r178910
Diffstat (limited to 'libgo/go/os/exec_plan9.go')
-rw-r--r--libgo/go/os/exec_plan9.go45
1 files changed, 42 insertions, 3 deletions
diff --git a/libgo/go/os/exec_plan9.go b/libgo/go/os/exec_plan9.go
index 11874ab..6f0722a 100644
--- a/libgo/go/os/exec_plan9.go
+++ b/libgo/go/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,38 @@ func StartProcess(name string, argv []string, attr *ProcAttr) (p *Process, err E
return newProcess(pid, h), nil
}
+// Plan9Note implements the Signal interface on Plan 9.
+type Plan9Note string
+
+func (note Plan9Note) String() string {
+ return string(note)
+}
+
+func (p *Process) Signal(sig Signal) Error {
+ if p.done {
+ return NewError("os: process already finished")
+ }
+
+ f, e := OpenFile("/proc/"+itoa(p.Pid)+"/note", O_WRONLY, 0)
+ if iserror(e) {
+ return NewSyscallError("signal", e)
+ }
+ defer f.Close()
+ _, e = f.Write([]byte(sig.String()))
+ return e
+}
+
+// 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 +84,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
@@ -71,11 +106,12 @@ func (p *Process) Wait(options int) (w *Waitmsg, err Error) {
}
if waitmsg.Pid == p.Pid {
+ p.done = true
break
}
}
- return (*Waitmsg)(&waitmsg), nil
+ return &Waitmsg{waitmsg}, nil
}
// Wait waits for process pid to exit or stop, and then returns a
@@ -109,6 +145,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
}