mirror of
https://github.com/golang/go
synced 2024-11-19 08:44:39 -07: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:
parent
dde435587d
commit
0bf36ce8fb
@ -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() }
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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.
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user