Files
runc/internal/linux/eintr.go
T
Kir Kolyshkin 8cc1eb379b Introduce and use internal/linux
This package is to provide unix.* wrappers to ensure that:
 - they retry on EINTR;
 - a "rich" error is returned on failure.

 A first such wrapper, Sendmsg, is introduced.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-26 14:16:50 -07:00

19 lines
295 B
Go

package linux
import (
"errors"
"golang.org/x/sys/unix"
)
// retryOnEINTR takes a function that returns an error and calls it
// until the error returned is not EINTR.
func retryOnEINTR(fn func() error) error {
for {
err := fn()
if !errors.Is(err, unix.EINTR) {
return err
}
}
}