From da4cebcfe26fcbb8c89843659866d18e88478f2e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 21 Jun 2017 09:42:13 +0200 Subject: [PATCH] libcontainer: use Eventfd() from x/sys/unix Use unix.Eventfd() instead of calling manually reimplementing it using the raw syscall. Also use the correct corresponding unix.EFD_CLOEXEC flag instead of unix.FD_CLOEXEC (which can have a different value on some architectures and thus might lead to unexpected behavior). Signed-off-by: Tobias Klauser --- libcontainer/notify_linux.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libcontainer/notify_linux.go b/libcontainer/notify_linux.go index 6da315d3..81587b9b 100644 --- a/libcontainer/notify_linux.go +++ b/libcontainer/notify_linux.go @@ -26,13 +26,13 @@ func registerMemoryEvent(cgDir string, evName string, arg string) (<-chan struct if err != nil { return nil, err } - fd, _, syserr := unix.RawSyscall(unix.SYS_EVENTFD2, 0, unix.FD_CLOEXEC, 0) - if syserr != 0 { + fd, err := unix.Eventfd(0, unix.EFD_CLOEXEC) + if err != nil { evFile.Close() - return nil, syserr + return nil, err } - eventfd := os.NewFile(fd, "eventfd") + eventfd := os.NewFile(uintptr(fd), "eventfd") eventControlPath := filepath.Join(cgDir, "cgroup.event_control") data := fmt.Sprintf("%d %d %s", eventfd.Fd(), evFile.Fd(), arg)