mirror of https://github.com/golang/go.git
os: release process handle at the end of windows (*Process).Wait
Fixes #3154. R=golang-dev, bradfitz, rsc CC=golang-dev https://golang.org/cl/5707052
This commit is contained in:
parent
532c1b451b
commit
ed238ca4e5
|
|
@ -36,7 +36,6 @@ func run(stdin []byte, argv []string) (stdout, stderr []byte, ok bool) {
|
|||
if err != nil {
|
||||
fatalf("%s", err)
|
||||
}
|
||||
defer p.Release()
|
||||
r0.Close()
|
||||
w1.Close()
|
||||
w2.Close()
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ func exec(rw http.ResponseWriter, args []string) (status int) {
|
|||
log.Printf("os.StartProcess(%q): %v", bin, err)
|
||||
return 2
|
||||
}
|
||||
defer p.Release()
|
||||
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, r)
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@ func DateServer(rw http.ResponseWriter, req *http.Request) {
|
|||
fmt.Fprintf(rw, "fork/exec: %s\n", err)
|
||||
return
|
||||
}
|
||||
defer p.Release()
|
||||
io.Copy(rw, r)
|
||||
wait, err := p.Wait(0)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,13 @@ func FindProcess(pid int) (p *Process, err error) {
|
|||
return findProcess(pid)
|
||||
}
|
||||
|
||||
// Release releases any resources associated with the Process p,
|
||||
// rendering it unusable in the future.
|
||||
// Release only needs to be called if Wait is not.
|
||||
func (p *Process) Release() error {
|
||||
return p.release()
|
||||
}
|
||||
|
||||
// Hostname returns the host name reported by the kernel.
|
||||
func Hostname() (name string, err error) {
|
||||
return hostname()
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ func (p *Process) Wait() (ps *ProcessState, err error) {
|
|||
return ps, nil
|
||||
}
|
||||
|
||||
// Release releases any resources associated with the Process.
|
||||
func (p *Process) Release() error {
|
||||
func (p *Process) release() error {
|
||||
// NOOP for Plan 9.
|
||||
p.Pid = -1
|
||||
// no need for a finalizer anymore
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ func (p *Process) Signal(sig Signal) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Release releases any resources associated with the Process.
|
||||
func (p *Process) Release() error {
|
||||
func (p *Process) release() error {
|
||||
// NOOP for unix.
|
||||
p.Pid = -1
|
||||
// no need for a finalizer anymore
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import (
|
|||
|
||||
// Wait waits for the Process to exit or stop, and then returns a
|
||||
// ProcessState describing its status and an error, if any.
|
||||
// Wait releases any resources associated with the Process.
|
||||
func (p *Process) Wait() (ps *ProcessState, err error) {
|
||||
s, e := syscall.WaitForSingleObject(syscall.Handle(p.handle), syscall.INFINITE)
|
||||
switch s {
|
||||
|
|
@ -30,6 +31,7 @@ func (p *Process) Wait() (ps *ProcessState, err error) {
|
|||
return nil, NewSyscallError("GetExitCodeProcess", e)
|
||||
}
|
||||
p.done = true
|
||||
defer p.Release()
|
||||
return &ProcessState{p.Pid, syscall.WaitStatus{Status: s, ExitCode: ec}, new(syscall.Rusage)}, nil
|
||||
}
|
||||
|
||||
|
|
@ -46,8 +48,7 @@ func (p *Process) Signal(sig Signal) error {
|
|||
return syscall.Errno(syscall.EWINDOWS)
|
||||
}
|
||||
|
||||
// Release releases any resources associated with the Process.
|
||||
func (p *Process) Release() error {
|
||||
func (p *Process) release() error {
|
||||
if p.handle == uintptr(syscall.InvalidHandle) {
|
||||
return syscall.EINVAL
|
||||
}
|
||||
|
|
|
|||
|
|
@ -530,7 +530,6 @@ func exec(t *testing.T, dir, cmd string, args []string, expect string) {
|
|||
if err != nil {
|
||||
t.Fatalf("StartProcess: %v", err)
|
||||
}
|
||||
defer p.Release()
|
||||
w.Close()
|
||||
|
||||
var b bytes.Buffer
|
||||
|
|
@ -848,7 +847,6 @@ func run(t *testing.T, cmd []string) string {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer p.Release()
|
||||
w.Close()
|
||||
|
||||
var b bytes.Buffer
|
||||
|
|
|
|||
Loading…
Reference in New Issue