aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec.go
diff options
context:
space:
mode:
authorcuiweixie <cuiweixie@gmail.com>2022-08-27 10:13:50 +0800
committerGopher Robot <gobot@golang.org>2022-09-15 21:11:27 +0000
commitdedce99c06c85c25f5e999ee55691648486dd934 (patch)
tree5a35cd2e4aa153f18f5901d9bed7b5036cb26c70 /src/os/exec.go
parente50dd0e974bdd621e48de2f64e02b4db5d12b393 (diff)
downloadgo-dedce99c06c85c25f5e999ee55691648486dd934.tar.xz
os: convert Process.isdone to atomic type
Change-Id: Ia3213d22678be0d56bf4f34dfe458441f7f5da97 Reviewed-on: https://go-review.googlesource.com/c/go/+/426077 Run-TryBot: Michael Pratt <mpratt@google.com> Run-TryBot: Jenny Rakoczy <jenny@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Jenny Rakoczy <jenny@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Jenny Rakoczy <jenny@golang.org>
Diffstat (limited to 'src/os/exec.go')
-rw-r--r--src/os/exec.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/os/exec.go b/src/os/exec.go
index 9eb3166ecb..d01ca592ba 100644
--- a/src/os/exec.go
+++ b/src/os/exec.go
@@ -21,7 +21,7 @@ var ErrProcessDone = errors.New("os: process already finished")
type Process struct {
Pid int
handle uintptr // handle is accessed atomically on Windows
- isdone uint32 // process has been successfully waited on, non zero if true
+ isdone atomic.Bool // process has been successfully waited on
sigMu sync.RWMutex // avoid race between wait and signal
}
@@ -32,11 +32,11 @@ func newProcess(pid int, handle uintptr) *Process {
}
func (p *Process) setDone() {
- atomic.StoreUint32(&p.isdone, 1)
+ p.isdone.Store(true)
}
func (p *Process) done() bool {
- return atomic.LoadUint32(&p.isdone) > 0
+ return p.isdone.Load()
}
// ProcAttr holds the attributes that will be applied to a new process