diff options
| author | Kir Kolyshkin <kolyshkin@gmail.com> | 2023-11-23 11:43:56 -0800 |
|---|---|---|
| committer | Michael Pratt <mpratt@google.com> | 2024-02-21 21:23:31 +0000 |
| commit | 4cd743e27eef7495a71cee08a9e8ca971ffcc0a5 (patch) | |
| tree | db366a92af0779c46bf9732f1a549835b23f564e /src/os/exec.go | |
| parent | b27d02c07b7bdb896f279a386fde8cb5ce284ec9 (diff) | |
| download | go-4cd743e27eef7495a71cee08a9e8ca971ffcc0a5.tar.xz | |
os: use atomic.Uintptr for Process.handle
Suggested-by: Michael Knyszek <mknyszek@google.com>
Change-Id: I116731b6c3738aae8ff1d3be227f8f51fa3320c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/544795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/os/exec.go')
| -rw-r--r-- | src/os/exec.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/os/exec.go b/src/os/exec.go index ed5a75c4d1..42e8a399a9 100644 --- a/src/os/exec.go +++ b/src/os/exec.go @@ -20,13 +20,14 @@ var ErrProcessDone = errors.New("os: process already finished") // Process stores the information about a process created by StartProcess. type Process struct { Pid int - handle uintptr // handle is accessed atomically on Windows + handle atomic.Uintptr isdone atomic.Bool // process has been successfully waited on sigMu sync.RWMutex // avoid race between wait and signal } func newProcess(pid int, handle uintptr) *Process { - p := &Process{Pid: pid, handle: handle} + p := &Process{Pid: pid} + p.handle.Store(handle) runtime.SetFinalizer(p, (*Process).Release) return p } |
