1
0
mirror of https://github.com/golang/go synced 2024-10-01 22:18:32 -06:00

os: Plan 9: add Process.Signal as a way to send notes.

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
This commit is contained in:
Yuval Pavel Zholkover 2011-07-13 16:29:37 -07:00 committed by Russ Cox
parent dde435587d
commit 0bf36ce8fb
4 changed files with 27 additions and 20 deletions

View File

@ -46,6 +46,11 @@ type ProcAttr struct {
Sys *syscall.SysProcAttr Sys *syscall.SysProcAttr
} }
// A Signal can represent any operating system signal.
type Signal interface {
String() string
}
// Getpid returns the process id of the caller. // Getpid returns the process id of the caller.
func Getpid() int { return syscall.Getpid() } func Getpid() int { return syscall.Getpid() }

View File

@ -38,6 +38,27 @@ func StartProcess(name string, argv []string, attr *ProcAttr) (p *Process, err E
return newProcess(pid, h), nil 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. // Kill causes the Process to exit immediately.
func (p *Process) Kill() Error { func (p *Process) Kill() Error {
f, e := OpenFile("/proc/"+itoa(p.Pid)+"/ctl", O_WRONLY, 0) 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 { if waitmsg.Pid == p.Pid {
p.done = true
break break
} }
} }

View File

@ -9,11 +9,6 @@ import (
"syscall" "syscall"
) )
// A Signal can represent any operating system signal.
type Signal interface {
String() string
}
type UnixSignal int32 type UnixSignal int32
func (sig UnixSignal) String() string { func (sig UnixSignal) String() string {

View File

@ -14,7 +14,6 @@ type File struct {
fd int fd int
name string name string
dirinfo *dirInfo // nil unless directory being read 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. // Fd returns the integer Unix file descriptor referencing the open file.
@ -273,20 +272,6 @@ func Chmod(name string, mode uint32) Error {
return nil 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 // Chtimes changes the access and modification times of the named
// file, similar to the Unix utime() or utimes() functions. // file, similar to the Unix utime() or utimes() functions.
// //