I have to use a certain cross-platform library which passes FILE*
objects around.
I get a file descriptor from another source (inherited), I want to keep same fd
across fork
'd processes.
I currently use fdopen
to convert a file descriptor to a FILE*
object.
My problem is that fclose
used to clean up FILE*
objects closes connected file descriptor.
I would very much like to keep this file descriptor after it has been used.
is there a way rescue file descriptor from FILE*
?
Is there a way to detach it?
Or a way to substitute a file descriptor in FILE*
with a dummy?
P.S. this needs to be cross-platform, well across POSIX anyway.