aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/proc/files.go
blob: 712713a2337e181fd36ff0155d723924a9c6eba2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package proc

import (
	"os"
	"os/exec"
)

func ExtraFile(cmd *exec.Cmd, f *os.File) (fd uintptr) {
	return ExtraFileSlice(&cmd.ExtraFiles, f)
}

func ExtraFileSlice(extraFiles *[]*os.File, f *os.File) (fd uintptr) {
	// ExtraFiles: If non-nil, entry i becomes file descriptor 3+i.
	fd = uintptr(3 + len(*extraFiles))
	*extraFiles = append(*extraFiles, f)
	return
}