--- /dev/null
+// 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"
+
+func PidFDSendSignal(pidfd uintptr, s syscall.Signal) error {
+ _, _, errno := syscall.Syscall(pidfdSendSignalTrap, pidfd, uintptr(s), 0)
+ if errno != 0 {
+ return errno
+ }
+ return nil
+}
package unix
const (
- getrandomTrap uintptr = 355
- copyFileRangeTrap uintptr = 377
+ getrandomTrap uintptr = 355
+ copyFileRangeTrap uintptr = 377
+ pidfdSendSignalTrap uintptr = 424
)
package unix
const (
- getrandomTrap uintptr = 318
- copyFileRangeTrap uintptr = 326
+ getrandomTrap uintptr = 318
+ copyFileRangeTrap uintptr = 326
+ pidfdSendSignalTrap uintptr = 424
)
package unix
const (
- getrandomTrap uintptr = 384
- copyFileRangeTrap uintptr = 391
+ getrandomTrap uintptr = 384
+ copyFileRangeTrap uintptr = 391
+ pidfdSendSignalTrap uintptr = 424
)
// means only arm64 loong64 and riscv64 use the standard numbers.
const (
- getrandomTrap uintptr = 278
- copyFileRangeTrap uintptr = 285
+ getrandomTrap uintptr = 278
+ copyFileRangeTrap uintptr = 285
+ pidfdSendSignalTrap uintptr = 424
)
package unix
const (
- getrandomTrap uintptr = 5313
- copyFileRangeTrap uintptr = 5320
+ getrandomTrap uintptr = 5313
+ copyFileRangeTrap uintptr = 5320
+ pidfdSendSignalTrap uintptr = 5424
)
package unix
const (
- getrandomTrap uintptr = 4353
- copyFileRangeTrap uintptr = 4360
+ getrandomTrap uintptr = 4353
+ copyFileRangeTrap uintptr = 4360
+ pidfdSendSignalTrap uintptr = 4424
)
package unix
const (
- getrandomTrap uintptr = 359
- copyFileRangeTrap uintptr = 379
+ getrandomTrap uintptr = 359
+ copyFileRangeTrap uintptr = 379
+ pidfdSendSignalTrap uintptr = 424
)
package unix
const (
- getrandomTrap uintptr = 349
- copyFileRangeTrap uintptr = 375
+ getrandomTrap uintptr = 349
+ copyFileRangeTrap uintptr = 375
+ pidfdSendSignalTrap uintptr = 424
)
"flag"
"fmt"
"internal/platform"
+ "internal/syscall/unix"
"internal/testenv"
"io"
"os"
// Use pidfd to send a signal to the child.
sig := syscall.SIGINT
- if _, _, e := syscall.Syscall(syscall.Sys_pidfd_send_signal, uintptr(pidfd), uintptr(sig), 0); e != 0 {
- if e != syscall.EINVAL && testenv.SyscallIsNotSupported(e) {
- t.Skip("pidfd_send_signal syscall not supported:", e)
+ if err := unix.PidFDSendSignal(uintptr(pidfd), sig); err != nil {
+ if err != syscall.EINVAL && testenv.SyscallIsNotSupported(err) {
+ t.Skip("pidfd_send_signal syscall not supported:", err)
}
- t.Fatal("pidfd_send_signal syscall failed:", e)
+ t.Fatal("pidfd_send_signal syscall failed:", err)
}
// Check if the child received our signal.
err = cmd.Wait()
)
const (
- Sys_GETEUID = sys_GETEUID
- Sys_pidfd_send_signal = _SYS_pidfd_send_signal
+ Sys_GETEUID = sys_GETEUID
)
import "unsafe"
const (
- _SYS_setgroups = SYS_SETGROUPS32
- _SYS_clone3 = 435
- _SYS_faccessat2 = 439
- _SYS_pidfd_send_signal = 424
- _SYS_fchmodat2 = 452
+ _SYS_setgroups = SYS_SETGROUPS32
+ _SYS_clone3 = 435
+ _SYS_faccessat2 = 439
+ _SYS_fchmodat2 = 452
)
func setTimespec(sec, nsec int64) Timespec {
)
const (
- _SYS_setgroups = SYS_SETGROUPS
- _SYS_clone3 = 435
- _SYS_faccessat2 = 439
- _SYS_pidfd_send_signal = 424
- _SYS_fchmodat2 = 452
+ _SYS_setgroups = SYS_SETGROUPS
+ _SYS_clone3 = 435
+ _SYS_faccessat2 = 439
+ _SYS_fchmodat2 = 452
)
//sys Dup2(oldfd int, newfd int) (err error)
import "unsafe"
const (
- _SYS_setgroups = SYS_SETGROUPS32
- _SYS_clone3 = 435
- _SYS_faccessat2 = 439
- _SYS_pidfd_send_signal = 424
- _SYS_fchmodat2 = 452
+ _SYS_setgroups = SYS_SETGROUPS32
+ _SYS_clone3 = 435
+ _SYS_faccessat2 = 439
+ _SYS_fchmodat2 = 452
)
func setTimespec(sec, nsec int64) Timespec {
import "unsafe"
const (
- _SYS_setgroups = SYS_SETGROUPS
- _SYS_clone3 = 435
- _SYS_faccessat2 = 439
- _SYS_pidfd_send_signal = 424
- _SYS_fchmodat2 = 452
+ _SYS_setgroups = SYS_SETGROUPS
+ _SYS_clone3 = 435
+ _SYS_faccessat2 = 439
+ _SYS_fchmodat2 = 452
)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT
import "unsafe"
const (
- _SYS_setgroups = SYS_SETGROUPS
- _SYS_clone3 = 435
- _SYS_faccessat2 = 439
- _SYS_pidfd_send_signal = 424
- _SYS_fchmodat2 = 452
+ _SYS_setgroups = SYS_SETGROUPS
+ _SYS_clone3 = 435
+ _SYS_faccessat2 = 439
+ _SYS_fchmodat2 = 452
)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT
)
const (
- _SYS_setgroups = SYS_SETGROUPS
- _SYS_clone3 = 5435
- _SYS_faccessat2 = 5439
- _SYS_pidfd_send_signal = 5424
- _SYS_fchmodat2 = 5452
+ _SYS_setgroups = SYS_SETGROUPS
+ _SYS_clone3 = 5435
+ _SYS_faccessat2 = 5439
+ _SYS_fchmodat2 = 5452
)
//sys Dup2(oldfd int, newfd int) (err error)
import "unsafe"
const (
- _SYS_setgroups = SYS_SETGROUPS
- _SYS_clone3 = 4435
- _SYS_faccessat2 = 4439
- _SYS_pidfd_send_signal = 4424
- _SYS_fchmodat2 = 4452
+ _SYS_setgroups = SYS_SETGROUPS
+ _SYS_clone3 = 4435
+ _SYS_faccessat2 = 4439
+ _SYS_fchmodat2 = 4452
)
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)
)
const (
- _SYS_setgroups = SYS_SETGROUPS
- _SYS_clone3 = 435
- _SYS_faccessat2 = 439
- _SYS_pidfd_send_signal = 424
- _SYS_fchmodat2 = 452
+ _SYS_setgroups = SYS_SETGROUPS
+ _SYS_clone3 = 435
+ _SYS_faccessat2 = 439
+ _SYS_fchmodat2 = 452
)
//sys Dup2(oldfd int, newfd int) (err error)
import "unsafe"
const (
- _SYS_setgroups = SYS_SETGROUPS
- _SYS_clone3 = 435
- _SYS_faccessat2 = 439
- _SYS_pidfd_send_signal = 424
- _SYS_fchmodat2 = 452
+ _SYS_setgroups = SYS_SETGROUPS
+ _SYS_clone3 = 435
+ _SYS_faccessat2 = 439
+ _SYS_fchmodat2 = 452
)
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT
import "unsafe"
const (
- _SYS_setgroups = SYS_SETGROUPS
- _SYS_clone3 = 435
- _SYS_faccessat2 = 439
- _SYS_pidfd_send_signal = 424
- _SYS_fchmodat2 = 452
+ _SYS_setgroups = SYS_SETGROUPS
+ _SYS_clone3 = 435
+ _SYS_faccessat2 = 439
+ _SYS_fchmodat2 = 452
)
//sys Dup2(oldfd int, newfd int) (err error)