mirror of
https://github.com/golang/go.git
synced 2025-05-18 05:44:35 +00:00
os: export ErrProcessDone variable in windows and plan9
Exposes ErrProcessDone variable in windows and plan9 also returns this error code instead of errors.New("os: process already finished") Fixes #42311 Change-Id: Ie807b6526e7b6c27636e6bffe5ff0c904b319be4 GitHub-Last-Rev: 2153e0d7020d8ee9e94087d02977ea049b7fd6a0 GitHub-Pull-Request: golang/go#42313 Reviewed-on: https://go-review.googlesource.com/c/go/+/266997 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
parent
ebc1b8ef28
commit
45205bc47b
@ -5,6 +5,7 @@
|
|||||||
package os
|
package os
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"internal/testlog"
|
"internal/testlog"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
@ -13,6 +14,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ErrProcessDone indicates a Process has finished.
|
||||||
|
var ErrProcessDone = errors.New("os: process already finished")
|
||||||
|
|
||||||
// Process stores the information about a process created by StartProcess.
|
// Process stores the information about a process created by StartProcess.
|
||||||
type Process struct {
|
type Process struct {
|
||||||
Pid int
|
Pid int
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
package os
|
package os
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@ -52,7 +51,7 @@ func (p *Process) writeProcFile(file string, data string) error {
|
|||||||
|
|
||||||
func (p *Process) signal(sig Signal) error {
|
func (p *Process) signal(sig Signal) error {
|
||||||
if p.done() {
|
if p.done() {
|
||||||
return errors.New("os: process already finished")
|
return ErrProcessDone
|
||||||
}
|
}
|
||||||
if e := p.writeProcFile("note", sig.String()); e != nil {
|
if e := p.writeProcFile("note", sig.String()); e != nil {
|
||||||
return NewSyscallError("signal", e)
|
return NewSyscallError("signal", e)
|
||||||
|
@ -59,9 +59,6 @@ func (p *Process) wait() (ps *ProcessState, err error) {
|
|||||||
return ps, nil
|
return ps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrProcessDone indicates a Process has finished.
|
|
||||||
var ErrProcessDone = errors.New("os: process already finished")
|
|
||||||
|
|
||||||
func (p *Process) signal(sig Signal) error {
|
func (p *Process) signal(sig Signal) error {
|
||||||
if p.Pid == -1 {
|
if p.Pid == -1 {
|
||||||
return errors.New("os: process already released")
|
return errors.New("os: process already released")
|
||||||
|
@ -61,7 +61,7 @@ func (p *Process) signal(sig Signal) error {
|
|||||||
return syscall.EINVAL
|
return syscall.EINVAL
|
||||||
}
|
}
|
||||||
if p.done() {
|
if p.done() {
|
||||||
return errors.New("os: process already finished")
|
return ErrProcessDone
|
||||||
}
|
}
|
||||||
if sig == Kill {
|
if sig == Kill {
|
||||||
err := terminateProcess(p.Pid, 1)
|
err := terminateProcess(p.Pid, 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user