This is really not a beginner question but I'm not sure what list to post it on.
I've created a daemon library for easily building daemons and at some
point code was added to handle closing all fd's so the daemonized
process would not have fd's hanging around it shouldn't have or didn't
expect to have. The code to close the fd was using POSIX::close(),
and this was a bad idea because, though it closes the fd, it leaves
any perl filehandles associated with the fd hanging around. This
makes for really twisty and perplexing bugs.
So I don't want to do that, but I can't figure out for the life of me
how to get a hold of all filehandles associated with an fd, or to
close all filehandles associated with an fd. Is there a way to do
this? I tried walking through the symbol tables, but that won't get
lexically scoped and localized filehandles. How does one do this?
BTW, at this moment I'm looking through perlio.c to try to see how the
filehandles and fd's are managed internally. If I had to I could
write a c routine to do this and expose it through XS. Any clues in
this area though, would be nice (like is there something already in
perlio.c to do this (-:).
And of course pointing me to a more appropriate list is fine too.