diff options
| author | Ian Lance Taylor <iant@golang.org> | 2024-09-06 12:19:01 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-09-18 19:41:05 +0000 |
| commit | c8c6f9abfbbd2f949285a527036a3d0dbd991e74 (patch) | |
| tree | 95570f55e4cee55c64ee1804555844e28faeb166 /src/syscall/exec_linux.go | |
| parent | a74951c5af5498db5d4be0c14dcaa45fb452e23a (diff) | |
| download | go-c8c6f9abfbbd2f949285a527036a3d0dbd991e74.tar.xz | |
[release-branch.go1.23] syscall: on exec failure, close pidfd
For #69284
Fixes #69402
Change-Id: I6350209302778ba5e44fa03d0b9e680d2b4ec192
Reviewed-on: https://go-review.googlesource.com/c/go/+/611495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: roger peppe <rogpeppe@gmail.com>
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
(cherry picked from commit 8926ca9c5ec3ea0b51e413e87f737aeb1422ea48)
Reviewed-on: https://go-review.googlesource.com/c/go/+/613616
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Diffstat (limited to 'src/syscall/exec_linux.go')
| -rw-r--r-- | src/syscall/exec_linux.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/syscall/exec_linux.go b/src/syscall/exec_linux.go index e4b9ce1bf4..2684412191 100644 --- a/src/syscall/exec_linux.go +++ b/src/syscall/exec_linux.go @@ -735,3 +735,11 @@ func writeUidGidMappings(pid int, sys *SysProcAttr) error { return nil } + +// forkAndExecFailureCleanup cleans up after an exec failure. +func forkAndExecFailureCleanup(attr *ProcAttr, sys *SysProcAttr) { + if sys.PidFD != nil && *sys.PidFD != -1 { + Close(*sys.PidFD) + *sys.PidFD = -1 + } +} |
