On Fri, Dec 11, 2009 at 4:36 PM, Shawn H Corey <shawnhco...@gmail.com> wrote: > James Olin Oden wrote: >> Hi All, >> >> 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. >> >> Thanks...james >> > > All daemons should periodically kill themselves and restart. This will: > Shawn good point. Do you know a way to handle the initial fd leak upon first fork? Remember this is a library that handles daemonization for some unknown program. The goal is to close all filed descriptors except the ones they tell me not close (or to not close them at all if they specify this). This is actually as much a security feature as anything. Right now though, being in this library I don't know of any means to figure out without them telling what FileHandles have been opened before calling my daemonize function. Is there a way to do this? or a way to get the FileHandles from the fd?
Thanks...james -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/