diff options
| author | Kir Kolyshkin <kolyshkin@gmail.com> | 2025-09-10 19:00:19 -0700 |
|---|---|---|
| committer | Kirill Kolyshkin <kolyshkin@gmail.com> | 2025-09-15 11:58:58 -0700 |
| commit | 3573227fe3fe8d141dbf06e257609a59871d5248 (patch) | |
| tree | 36e9503ef0846a301170cf44ceef5d4003258115 /src | |
| parent | 68c6a73380e82a0ea9a93c1a75ab8a38f28f3a3d (diff) | |
| download | go-3573227fe3fe8d141dbf06e257609a59871d5248.tar.xz | |
os: add and use errProcessReleased
This error is already used in three places, so let's define it.
Change-Id: I73565d94aebcf3d5a278201d96839d82db85a2d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/702436
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/os/exec.go | 8 | ||||
| -rw-r--r-- | src/os/exec_unix.go | 4 | ||||
| -rw-r--r-- | src/os/pidfd_linux.go | 3 |
3 files changed, 9 insertions, 6 deletions
diff --git a/src/os/exec.go b/src/os/exec.go index 43b33fe944..e14434d8b5 100644 --- a/src/os/exec.go +++ b/src/os/exec.go @@ -14,8 +14,12 @@ import ( "time" ) -// ErrProcessDone indicates a [Process] has finished. -var ErrProcessDone = errors.New("os: process already finished") +var ( + // ErrProcessDone indicates a [Process] has finished. + ErrProcessDone = errors.New("os: process already finished") + // errProcessReleased indicates a [Process] has been released. + errProcessReleased = errors.New("os: process already released") +) // processStatus describes the status of a [Process]. type processStatus uint32 diff --git a/src/os/exec_unix.go b/src/os/exec_unix.go index f9be8dc068..d2ceb0ceb5 100644 --- a/src/os/exec_unix.go +++ b/src/os/exec_unix.go @@ -92,7 +92,7 @@ func (p *Process) signal(sig Signal) error { func (p *Process) pidSignal(s syscall.Signal) error { if p.Pid == pidReleased { - return errors.New("os: process already released") + return errProcessReleased } if p.Pid == pidUnset { return errors.New("os: process not initialized") @@ -105,7 +105,7 @@ func (p *Process) pidSignal(s syscall.Signal) error { case statusDone: return ErrProcessDone case statusReleased: - return errors.New("os: process already released") + return errProcessReleased } return convertESRCH(syscall.Kill(p.Pid, s)) diff --git a/src/os/pidfd_linux.go b/src/os/pidfd_linux.go index 59911e8824..796d8c018c 100644 --- a/src/os/pidfd_linux.go +++ b/src/os/pidfd_linux.go @@ -16,7 +16,6 @@ package os import ( - "errors" "internal/syscall/unix" "runtime" "sync" @@ -130,7 +129,7 @@ func (p *Process) pidfdSendSignal(s syscall.Signal) error { case statusDone: return ErrProcessDone case statusReleased: - return errors.New("os: process already released") + return errProcessReleased } defer p.handleTransientRelease() |
