mirror of
https://github.com/golang/go
synced 2024-11-22 04:44:39 -07:00
os: Process.handle use syscall.Handle
R=golang-dev, alex.brainman, rsc CC=golang-dev https://golang.org/cl/5605050
This commit is contained in:
parent
cdabb3d315
commit
16ce2f9369
@ -12,11 +12,11 @@ import (
|
||||
// Process stores the information about a process created by StartProcess.
|
||||
type Process struct {
|
||||
Pid int
|
||||
handle int
|
||||
handle uintptr
|
||||
done bool // process has been successfuly waited on
|
||||
}
|
||||
|
||||
func newProcess(pid, handle int) *Process {
|
||||
func newProcess(pid int, handle uintptr) *Process {
|
||||
p := &Process{Pid: pid, handle: handle}
|
||||
runtime.SetFinalizer(p, (*Process).Release)
|
||||
return p
|
||||
|
@ -46,14 +46,14 @@ func (p *Process) Signal(sig Signal) error {
|
||||
|
||||
// Release releases any resources associated with the Process.
|
||||
func (p *Process) Release() error {
|
||||
if p.handle == -1 {
|
||||
if p.handle == uintptr(syscall.InvalidHandle) {
|
||||
return EINVAL
|
||||
}
|
||||
e := syscall.CloseHandle(syscall.Handle(p.handle))
|
||||
if e != nil {
|
||||
return NewSyscallError("CloseHandle", e)
|
||||
}
|
||||
p.handle = -1
|
||||
p.handle = uintptr(syscall.InvalidHandle)
|
||||
// no need for a finalizer anymore
|
||||
runtime.SetFinalizer(p, nil)
|
||||
return nil
|
||||
@ -66,7 +66,7 @@ func findProcess(pid int) (p *Process, err error) {
|
||||
if e != nil {
|
||||
return nil, NewSyscallError("OpenProcess", e)
|
||||
}
|
||||
return newProcess(pid, int(h)), nil
|
||||
return newProcess(pid, uintptr(h)), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -483,7 +483,7 @@ func ForkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
|
||||
}
|
||||
|
||||
// StartProcess wraps ForkExec for package os.
|
||||
func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid, handle int, err error) {
|
||||
func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle uintptr, err error) {
|
||||
pid, err = forkExec(argv0, argv, attr)
|
||||
return pid, 0, err
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ func ForkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
|
||||
}
|
||||
|
||||
// StartProcess wraps ForkExec for package os.
|
||||
func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid, handle int, err error) {
|
||||
func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle uintptr, err error) {
|
||||
pid, err = forkExec(argv0, argv, attr)
|
||||
return pid, 0, err
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ type SysProcAttr struct {
|
||||
var zeroProcAttr ProcAttr
|
||||
var zeroSysProcAttr SysProcAttr
|
||||
|
||||
func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid, handle int, err error) {
|
||||
func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle uintptr, err error) {
|
||||
if len(argv0) == 0 {
|
||||
return 0, 0, EWINDOWS
|
||||
}
|
||||
@ -319,7 +319,7 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid, handle int,
|
||||
}
|
||||
defer CloseHandle(Handle(pi.Thread))
|
||||
|
||||
return int(pi.ProcessId), int(pi.Process), nil
|
||||
return int(pi.ProcessId), uintptr(pi.Process), nil
|
||||
}
|
||||
|
||||
func Exec(argv0 string, argv []string, envv []string) (err error) {
|
||||
|
Loading…
Reference in New Issue
Block a user