diff --git a/internal/proc/fd.go b/internal/proc/fd.go index 1d63427..5400abe 100644 --- a/internal/proc/fd.go +++ b/internal/proc/fd.go @@ -12,6 +12,16 @@ var ( ErrInvalid = errors.New("bad file descriptor") ) +func Setup(extraFiles *[]*os.File) (int, *gob.Encoder, error) { + if r, w, err := os.Pipe(); err != nil { + return -1, nil, err + } else { + fd := 3 + len(*extraFiles) + *extraFiles = append(*extraFiles, r) + return fd, gob.NewEncoder(w), nil + } +} + func Receive(key string, e any) (func() error, error) { var setup *os.File