From 82029948e6d8d047edc02ccff354e16c419e5742 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 21 Jan 2025 12:51:39 +0900 Subject: [PATCH] proc: append to ExtraFiles slice pointer This is useful for initialising extra files before command. Signed-off-by: Ophestra --- internal/proc/files.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/proc/files.go b/internal/proc/files.go index 5a5e1c2..712713a 100644 --- a/internal/proc/files.go +++ b/internal/proc/files.go @@ -6,8 +6,12 @@ import ( ) 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(cmd.ExtraFiles)) - cmd.ExtraFiles = append(cmd.ExtraFiles, f) + fd = uintptr(3 + len(*extraFiles)) + *extraFiles = append(*extraFiles, f) return }