I have an fmemopen file descriptor(pointing to a buffer in the parent) in Linux and I would like to be able to, in C, set this file descriptor as the standard input for a child process(for whom I do not have access to the code)
Is this possible? If so how do I do it? I would like to avoid having to write to disk if at all possible.
This is not possible. Inheriting stdin/out/err is based purely on file descriptors, not stdio FILE streams. Since fmemopen does not create a file descriptor, it cannot become a new process's stdin/out/err or be used for inter-process communication in any way. What you're looking for is a pipe, unless you need seeking, in which case you need a temporary file. The tmpfile function could be used to create one without having to worry about making a visible name in the filesystem.
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