aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/proc/files.go
diff options
context:
space:
mode:
Diffstat (limited to 'helper/proc/files.go')
-rw-r--r--helper/proc/files.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/helper/proc/files.go b/helper/proc/files.go
new file mode 100644
index 00000000..712713a2
--- /dev/null
+++ b/helper/proc/files.go
@@ -0,0 +1,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
+}