From ad584ebecb46fc0ae0f3a7d86c5566e1bc2918c6 Mon Sep 17 00:00:00 2001 From: Danny Canter Date: Wed, 10 Apr 2024 05:52:43 -0700 Subject: [PATCH] Replace direct waitid syscall with unix.Waitid This also replaces the PPidFD constant with the definition in x/sys/unix Signed-off-by: Danny Canter --- core/mount/mount_idmapped_linux.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/core/mount/mount_idmapped_linux.go b/core/mount/mount_idmapped_linux.go index 1e07ae47d..1b06e658a 100644 --- a/core/mount/mount_idmapped_linux.go +++ b/core/mount/mount_idmapped_linux.go @@ -190,17 +190,13 @@ func getUsernsFD(uidMaps, gidMaps []syscall.SysProcIDMap) (_usernsFD *os.File, r } func pidfdWaitid(pidFD *os.File) error { - // https://elixir.bootlin.com/linux/v5.4.258/source/include/uapi/linux/wait.h#L20 - const PPidFD = 3 - - var e syscall.Errno for { - _, _, e = syscall.Syscall6(syscall.SYS_WAITID, PPidFD, pidFD.Fd(), 0, syscall.WEXITED, 0, 0) - if e != syscall.EINTR { - break + err := unix.Waitid(unix.P_PIDFD, int(pidFD.Fd()), nil, unix.WEXITED, nil) + if err == unix.EINTR { + continue } + return err } - return e } var (