mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
8cc1eb379b
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>
19 lines
295 B
Go
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
|
|
}
|
|
}
|
|
}
|