aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/proc/files.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-02-08 13:03:45 +0900
committerOphestra <cat@gensokyo.uk>2025-02-08 13:03:45 +0900
commite14923ae530dda0601c204fe17ac1956f54a45b0 (patch)
tree1578bbc4c08d9afc94c4b009cd2bf64260574f05 /helper/proc/files.go
parent7aff3ead3afaa7461e0054fbef23fb571b4add0a (diff)
helper/proc: move package out of internal
Signed-off-by: Ophestra <cat@gensokyo.uk>
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
+}