From: Kir Kolyshkin Date: Thu, 11 Sep 2025 02:00:19 +0000 (-0700) Subject: os: add and use errProcessReleased X-Git-Tag: go1.26rc1~874 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3573227fe3;p=gostls13.git 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 Reviewed-by: Mark Freeman Reviewed-by: Sean Liao Reviewed-by: Michael Pratt --- 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()