From da7ee57f40069eda3488b2e51dfa878bdd5816af Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 16 Aug 2023 19:20:54 -0700 Subject: syscall: add support to get pidfd from ForkExec on Linux Add PidFD support, so that if the PidFD pointer in SysProcAttr is not nil, ForkExec (and thus all its users) obtains a pidfd from the kernel during clone(), and writes the result (or -1, if the functionality is not supported by the kernel) into *PidFD. The functionality to get pidfd is implemented for both clone3 and clone. For the latter, an extra argument to rawVforkSyscall is needed, thus the change in asm files. Add a trivial test case checking the obtained pidfd can be used to send a signal to a process, using pidfd_send_signal. To test clone3 code path, add a flag available to tests only. Updates #51246. Change-Id: I2212b69e1a657163c31b4a6245b076bc495777a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/520266 Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Cherry Mui Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot Run-TryBot: Kirill Kolyshkin --- src/syscall/syscall_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/syscall/syscall_linux.go') diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go index 8b0a57b502..e012c1b943 100644 --- a/src/syscall/syscall_linux.go +++ b/src/syscall/syscall_linux.go @@ -95,7 +95,7 @@ func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) } func rawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) -func rawVforkSyscall(trap, a1, a2 uintptr) (r1 uintptr, err Errno) +func rawVforkSyscall(trap, a1, a2, a3 uintptr) (r1 uintptr, err Errno) /* * Wrapped -- cgit v1.3-5-g9baa