I have the following opened FD (lsof output):
auth 11780 root 5w FIFO 0,10 0t0 72061824 pipe
I need to write something in FD 5 (FIFO) in go. In C it is performed by the syscall write():
19270 write(5, "*************", 12 <unfinished ...>
Thank you in advance!
Use os.NewFile
to "open" an existing file by its file descriptor:
func NewFile(fd uintptr, name string) *File
NewFile returns a new File with the given file descriptor and name.
file := os.NewFile(5, "pipe")
_, err := file.Write([]byte(`my data`))
if err != nil {
panic(err)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With