first commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
//go:build linux
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// createSocketPair creates a Unix domain socket pair
|
||||
func createSocketPair() ([2]int, error) {
|
||||
fds, err := unix.Socketpair(unix.AF_UNIX, unix.SOCK_STREAM, 0)
|
||||
if err != nil {
|
||||
return [2]int{}, fmt.Errorf("socketpair: %w", err)
|
||||
}
|
||||
return fds, nil
|
||||
}
|
||||
|
||||
func closeFDs(fds [2]int) {
|
||||
unix.Close(fds[0])
|
||||
unix.Close(fds[1])
|
||||
}
|
||||
|
||||
func fdToFile(fd int, name string) *os.File {
|
||||
return os.NewFile(uintptr(fd), name)
|
||||
}
|
||||
Reference in New Issue
Block a user