proc: append to ExtraFiles slice pointer
This is useful for initialising extra files before command. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
dfcdc5ce20
commit
82029948e6
@ -6,8 +6,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func ExtraFile(cmd *exec.Cmd, f *os.File) (fd uintptr) {
|
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.
|
// ExtraFiles: If non-nil, entry i becomes file descriptor 3+i.
|
||||||
fd = uintptr(3 + len(cmd.ExtraFiles))
|
fd = uintptr(3 + len(*extraFiles))
|
||||||
cmd.ExtraFiles = append(cmd.ExtraFiles, f)
|
*extraFiles = append(*extraFiles, f)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user