Retry direct unix package calls if observing EINTR

Retry Recvfrom, Sendmsg, Readmsg, and Read as they can return EINTR.

Signed-off-by: Evan Phoenix <evan@phx.io>
This commit is contained in:
Evan Phoenix
2025-02-20 12:52:55 -08:00
parent 91e6621205
commit 28475f12e3
3 changed files with 37 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package libcontainer
import (
"fmt"
"os"
"path/filepath"
"unsafe"
@@ -40,7 +41,11 @@ func registerMemoryEventV2(cgDir, evName, cgEvName string) (<-chan struct{}, err
for {
n, err := unix.Read(fd, buffer[:])
if err == unix.EINTR { //nolint:errorlint // unix errors are bare
continue
}
if err != nil {
err = os.NewSyscallError("read", err)
logrus.Warnf("unable to read event data from inotify, got error: %v", err)
return
}