diff options
| author | Michael Pratt <mpratt@google.com> | 2024-02-23 13:08:46 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-02-23 18:31:19 +0000 |
| commit | e58486e5991c7dc3ac65ef12421cb33b91dd3d9e (patch) | |
| tree | e5c27d3b01daec21b4bcdeaa54c37c23340f3f5e /src/internal/syscall | |
| parent | c4e4afc90eb6fd31710edb062bacfae0643d170f (diff) | |
| download | go-e58486e5991c7dc3ac65ef12421cb33b91dd3d9e.tar.xz | |
Revert "os: make use of pidfd on linux"
This reverts CL 528438.
Reason for revert: Implicated in "bad FD" test failures. Full extent of
issue still unclear.
For #62654.
Fixes #65857.
Change-Id: I066e38040544c506917e90255bd0e330964a0276
Reviewed-on: https://go-review.googlesource.com/c/go/+/566477
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/internal/syscall')
| -rw-r--r-- | src/internal/syscall/unix/pidfd_linux.go | 8 | ||||
| -rw-r--r-- | src/internal/syscall/unix/siginfo_linux.go | 64 | ||||
| -rw-r--r-- | src/internal/syscall/unix/siginfo_linux_mipsx.go | 12 | ||||
| -rw-r--r-- | src/internal/syscall/unix/siginfo_linux_other.go | 12 | ||||
| -rw-r--r-- | src/internal/syscall/unix/siginfo_linux_test.go | 59 | ||||
| -rw-r--r-- | src/internal/syscall/unix/sysnum_linux_386.go | 1 | ||||
| -rw-r--r-- | src/internal/syscall/unix/sysnum_linux_amd64.go | 1 | ||||
| -rw-r--r-- | src/internal/syscall/unix/sysnum_linux_arm.go | 1 | ||||
| -rw-r--r-- | src/internal/syscall/unix/sysnum_linux_generic.go | 1 | ||||
| -rw-r--r-- | src/internal/syscall/unix/sysnum_linux_mips64x.go | 1 | ||||
| -rw-r--r-- | src/internal/syscall/unix/sysnum_linux_mipsx.go | 1 | ||||
| -rw-r--r-- | src/internal/syscall/unix/sysnum_linux_ppc64x.go | 1 | ||||
| -rw-r--r-- | src/internal/syscall/unix/sysnum_linux_s390x.go | 1 |
13 files changed, 0 insertions, 163 deletions
diff --git a/src/internal/syscall/unix/pidfd_linux.go b/src/internal/syscall/unix/pidfd_linux.go index e9417623db..02cfaa062c 100644 --- a/src/internal/syscall/unix/pidfd_linux.go +++ b/src/internal/syscall/unix/pidfd_linux.go @@ -13,11 +13,3 @@ func PidFDSendSignal(pidfd uintptr, s syscall.Signal) error { } return nil } - -func PidFDOpen(pid, flags int) (uintptr, error) { - pidfd, _, errno := syscall.Syscall(pidfdOpenTrap, uintptr(pid), uintptr(flags), 0) - if errno != 0 { - return ^uintptr(0), errno - } - return uintptr(pidfd), nil -} diff --git a/src/internal/syscall/unix/siginfo_linux.go b/src/internal/syscall/unix/siginfo_linux.go deleted file mode 100644 index 9f83114e45..0000000000 --- a/src/internal/syscall/unix/siginfo_linux.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package unix - -import ( - "syscall" -) - -const is64bit = ^uint(0) >> 63 // 0 for 32-bit hosts, 1 for 64-bit ones. - -// SiginfoChild is a struct filled in by Linux waitid syscall. -// In C, siginfo_t contains a union with multiple members; -// this struct corresponds to one used when Signo is SIGCHLD. -// -// NOTE fields are exported to be used by TestSiginfoChildLayout. -type SiginfoChild struct { - Signo int32 - siErrnoCode // Two int32 fields, swapped on MIPS. - _ [is64bit]int32 // Extra padding for 64-bit hosts only. - - // End of common part. Beginning of signal-specific part. - - Pid int32 - Uid uint32 - Status int32 - - // Pad to 128 bytes. - _ [128 - (6+is64bit)*4]byte -} - -const ( - // Possible values for SiginfoChild.Code field. - _CLD_EXITED int32 = 1 - _CLD_KILLED = 2 - _CLD_DUMPED = 3 - _CLD_TRAPPED = 4 - _CLD_STOPPED = 5 - _CLD_CONTINUED = 6 - - // These are the same as in syscall/syscall_linux.go. - core = 0x80 - stopped = 0x7f - continued = 0xffff -) - -// WaitStatus converts SiginfoChild, as filled in by the waitid syscall, -// to syscall.WaitStatus. -func (s *SiginfoChild) WaitStatus() (ws syscall.WaitStatus) { - switch s.Code { - case _CLD_EXITED: - ws = syscall.WaitStatus(s.Status << 8) - case _CLD_DUMPED: - ws = syscall.WaitStatus(s.Status) | core - case _CLD_KILLED: - ws = syscall.WaitStatus(s.Status) - case _CLD_TRAPPED, _CLD_STOPPED: - ws = syscall.WaitStatus(s.Status<<8) | stopped - case _CLD_CONTINUED: - ws = continued - } - return -} diff --git a/src/internal/syscall/unix/siginfo_linux_mipsx.go b/src/internal/syscall/unix/siginfo_linux_mipsx.go deleted file mode 100644 index 2fca0c5505..0000000000 --- a/src/internal/syscall/unix/siginfo_linux_mipsx.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build linux && (mips || mipsle || mips64 || mips64le) - -package unix - -type siErrnoCode struct { - Code int32 - Errno int32 -} diff --git a/src/internal/syscall/unix/siginfo_linux_other.go b/src/internal/syscall/unix/siginfo_linux_other.go deleted file mode 100644 index cfdc4ddf51..0000000000 --- a/src/internal/syscall/unix/siginfo_linux_other.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build linux && !(mips || mipsle || mips64 || mips64le) - -package unix - -type siErrnoCode struct { - Errno int32 - Code int32 -} diff --git a/src/internal/syscall/unix/siginfo_linux_test.go b/src/internal/syscall/unix/siginfo_linux_test.go deleted file mode 100644 index 596c2ebee3..0000000000 --- a/src/internal/syscall/unix/siginfo_linux_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package unix_test - -import ( - "internal/goarch" - "internal/syscall/unix" - "runtime" - "strings" - "testing" - "unsafe" -) - -// TestSiginfoChildLayout validates SiginfoChild layout. Modelled after -// static assertions in linux kernel's arch/*/kernel/signal*.c. -func TestSiginfoChildLayout(t *testing.T) { - var si unix.SiginfoChild - - const host64bit = goarch.PtrSize == 8 - - if v := unsafe.Sizeof(si); v != 128 { - t.Fatalf("sizeof: got %d, want 128", v) - } - - ofSigno := 0 - ofErrno := 4 - ofCode := 8 - if strings.HasPrefix(runtime.GOARCH, "mips") { - // These two fields are swapped on MIPS platforms. - ofErrno, ofCode = ofCode, ofErrno - } - ofPid := 12 - if host64bit { - ofPid = 16 - } - ofUid := ofPid + 4 - ofStatus := ofPid + 8 - - offsets := []struct { - name string - got uintptr - want int - }{ - {"Signo", unsafe.Offsetof(si.Signo), ofSigno}, - {"Errno", unsafe.Offsetof(si.Errno), ofErrno}, - {"Code", unsafe.Offsetof(si.Code), ofCode}, - {"Pid", unsafe.Offsetof(si.Pid), ofPid}, - {"Uid", unsafe.Offsetof(si.Uid), ofUid}, - {"Status", unsafe.Offsetof(si.Status), ofStatus}, - } - - for _, tc := range offsets { - if int(tc.got) != tc.want { - t.Errorf("offsetof %s: got %d, want %d", tc.name, tc.got, tc.want) - } - } -} diff --git a/src/internal/syscall/unix/sysnum_linux_386.go b/src/internal/syscall/unix/sysnum_linux_386.go index be048bcf73..9f750a1c03 100644 --- a/src/internal/syscall/unix/sysnum_linux_386.go +++ b/src/internal/syscall/unix/sysnum_linux_386.go @@ -8,5 +8,4 @@ const ( getrandomTrap uintptr = 355 copyFileRangeTrap uintptr = 377 pidfdSendSignalTrap uintptr = 424 - pidfdOpenTrap uintptr = 434 ) diff --git a/src/internal/syscall/unix/sysnum_linux_amd64.go b/src/internal/syscall/unix/sysnum_linux_amd64.go index 525de9cbd8..706898d41e 100644 --- a/src/internal/syscall/unix/sysnum_linux_amd64.go +++ b/src/internal/syscall/unix/sysnum_linux_amd64.go @@ -8,5 +8,4 @@ const ( getrandomTrap uintptr = 318 copyFileRangeTrap uintptr = 326 pidfdSendSignalTrap uintptr = 424 - pidfdOpenTrap uintptr = 434 ) diff --git a/src/internal/syscall/unix/sysnum_linux_arm.go b/src/internal/syscall/unix/sysnum_linux_arm.go index b803892278..c00644b552 100644 --- a/src/internal/syscall/unix/sysnum_linux_arm.go +++ b/src/internal/syscall/unix/sysnum_linux_arm.go @@ -8,5 +8,4 @@ const ( getrandomTrap uintptr = 384 copyFileRangeTrap uintptr = 391 pidfdSendSignalTrap uintptr = 424 - pidfdOpenTrap uintptr = 434 ) diff --git a/src/internal/syscall/unix/sysnum_linux_generic.go b/src/internal/syscall/unix/sysnum_linux_generic.go index b06bf69273..bf25428e7e 100644 --- a/src/internal/syscall/unix/sysnum_linux_generic.go +++ b/src/internal/syscall/unix/sysnum_linux_generic.go @@ -14,5 +14,4 @@ const ( getrandomTrap uintptr = 278 copyFileRangeTrap uintptr = 285 pidfdSendSignalTrap uintptr = 424 - pidfdOpenTrap uintptr = 434 ) diff --git a/src/internal/syscall/unix/sysnum_linux_mips64x.go b/src/internal/syscall/unix/sysnum_linux_mips64x.go index 8764f5dc8f..6a9e238ce3 100644 --- a/src/internal/syscall/unix/sysnum_linux_mips64x.go +++ b/src/internal/syscall/unix/sysnum_linux_mips64x.go @@ -10,5 +10,4 @@ const ( getrandomTrap uintptr = 5313 copyFileRangeTrap uintptr = 5320 pidfdSendSignalTrap uintptr = 5424 - pidfdOpenTrap uintptr = 5434 ) diff --git a/src/internal/syscall/unix/sysnum_linux_mipsx.go b/src/internal/syscall/unix/sysnum_linux_mipsx.go index 9b2e587ba5..22d38f148e 100644 --- a/src/internal/syscall/unix/sysnum_linux_mipsx.go +++ b/src/internal/syscall/unix/sysnum_linux_mipsx.go @@ -10,5 +10,4 @@ const ( getrandomTrap uintptr = 4353 copyFileRangeTrap uintptr = 4360 pidfdSendSignalTrap uintptr = 4424 - pidfdOpenTrap uintptr = 4434 ) diff --git a/src/internal/syscall/unix/sysnum_linux_ppc64x.go b/src/internal/syscall/unix/sysnum_linux_ppc64x.go index 03e9c19743..945ec28c2a 100644 --- a/src/internal/syscall/unix/sysnum_linux_ppc64x.go +++ b/src/internal/syscall/unix/sysnum_linux_ppc64x.go @@ -10,5 +10,4 @@ const ( getrandomTrap uintptr = 359 copyFileRangeTrap uintptr = 379 pidfdSendSignalTrap uintptr = 424 - pidfdOpenTrap uintptr = 434 ) diff --git a/src/internal/syscall/unix/sysnum_linux_s390x.go b/src/internal/syscall/unix/sysnum_linux_s390x.go index c6e3e02e46..2c74343820 100644 --- a/src/internal/syscall/unix/sysnum_linux_s390x.go +++ b/src/internal/syscall/unix/sysnum_linux_s390x.go @@ -8,5 +8,4 @@ const ( getrandomTrap uintptr = 349 copyFileRangeTrap uintptr = 375 pidfdSendSignalTrap uintptr = 424 - pidfdOpenTrap uintptr = 434 ) |
