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>
This commit is contained in:
Kir Kolyshkin
2025-03-25 14:24:20 -07:00
parent e5895f1100
commit 8cc1eb379b
4 changed files with 39 additions and 9 deletions

15
internal/linux/linux.go Normal file
View File

@@ -0,0 +1,15 @@
package linux
import (
"os"
"golang.org/x/sys/unix"
)
// Sendmsg wraps [unix.Sendmsg].
func Sendmsg(fd int, p, oob []byte, to unix.Sockaddr, flags int) error {
err := retryOnEINTR(func() error {
return unix.Sendmsg(fd, p, oob, to, flags)
})
return os.NewSyscallError("sendmsg", err)
}