]> Cypherpunks repositories - gostls13.git/commitdiff
os: Plan 9: add Process.Signal as a way to send notes.
authorYuval Pavel Zholkover <paulzhol@gmail.com>
Wed, 13 Jul 2011 23:29:37 +0000 (16:29 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 13 Jul 2011 23:29:37 +0000 (16:29 -0700)
Move the Signal interface from exec_posix.go to exec.go.
Remove some unsused code from file_plan9.go.

R=fshahriar, rsc
CC=golang-dev
https://golang.org/cl/4683044

src/pkg/os/exec.go
src/pkg/os/exec_plan9.go
src/pkg/os/exec_posix.go
src/pkg/os/file_plan9.go

index 40e6c1774ee817228dabc9f2ab889f276be945b4..33e223fd2963dcff621fcf8cc2365a33ff545153 100644 (file)
@@ -46,6 +46,11 @@ type ProcAttr struct {
        Sys *syscall.SysProcAttr
 }
 
+// A Signal can represent any operating system signal.
+type Signal interface {
+       String() string
+}
+
 // Getpid returns the process id of the caller.
 func Getpid() int { return syscall.Getpid() }
 
index 2590dd67de2a5882593d69f169f75112e5736e5d..6f0722a222ebc029023deb4c3c048e9d3e5bb823 100644 (file)
@@ -38,6 +38,27 @@ 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)
@@ -85,6 +106,7 @@ func (p *Process) Wait(options int) (w *Waitmsg, err Error) {
                }
 
                if waitmsg.Pid == p.Pid {
+                       p.done = true
                        break
                }
        }
index e2097700e970efcd3375f75278d35e852f788c61..813b96846759cec86f5c1bdbefef7c813861c2ad 100644 (file)
@@ -9,11 +9,6 @@ import (
        "syscall"
 )
 
-// A Signal can represent any operating system signal.
-type Signal interface {
-       String() string
-}
-
 type UnixSignal int32
 
 func (sig UnixSignal) String() string {
index 03792191ecc30b873922cdf2cf4a8a58836ccb30..f196ea9a65dc1726198e91510f38a53108ee70ce 100644 (file)
@@ -14,7 +14,6 @@ type File struct {
        fd      int
        name    string
        dirinfo *dirInfo // nil unless directory being read
-       nepipe  int      // number of consecutive EPIPE in Write
 }
 
 // Fd returns the integer Unix file descriptor referencing the open file.
@@ -273,20 +272,6 @@ func Chmod(name string, mode uint32) Error {
        return nil
 }
 
-// ChownPlan9 changes the uid and gid strings of the named file.
-func ChownPlan9(name, uid, gid string) Error {
-       var d Dir
-       d.Null()
-
-       d.Uid = uid
-       d.Gid = gid
-
-       if e := syscall.Wstat(name, pdir(nil, &d)); iserror(e) {
-               return &PathError{"chown_plan9", name, e}
-       }
-       return nil
-}
-
 // Chtimes changes the access and modification times of the named
 // file, similar to the Unix utime() or utimes() functions.
 //