// 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
// 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
if e != nil {
return nil, NewSyscallError("OpenProcess", e)
}
- return newProcess(pid, int(h)), nil
+ return newProcess(pid, uintptr(h)), nil
}
func init() {
}
// 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
}
}
// 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
}
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
}
}
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) {