2024-12-06 16:05:04 +09:00
|
|
|
package proc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ExtraFile(cmd *exec.Cmd, f *os.File) (fd uintptr) {
|
2025-01-21 12:51:39 +09:00
|
|
|
return ExtraFileSlice(&cmd.ExtraFiles, f)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExtraFileSlice(extraFiles *[]*os.File, f *os.File) (fd uintptr) {
|
2024-12-06 16:05:04 +09:00
|
|
|
// ExtraFiles: If non-nil, entry i becomes file descriptor 3+i.
|
2025-01-21 12:51:39 +09:00
|
|
|
fd = uintptr(3 + len(*extraFiles))
|
|
|
|
*extraFiles = append(*extraFiles, f)
|
2024-12-06 16:05:04 +09:00
|
|
|
return
|
|
|
|
}
|