A
Ara.T.Howard
i just discovered a subtle bugette (no harm done except nfs silly name
created) in some code i had written that is caused by forking with open file
descriptors followed by a close/unlink in the parent. the child never uses
the file and so it's not really an 'error' - but on nfs this will cause a
sillyname to appear (.nfsxxxxxxxx) and remain until the child exits which, in
this case, can be up to five days later and i have dozens of these guys
cluttering up my directories since this code runs on dozens of machine
simoutaneously.
i'm wondering - is there some way in ruby to obtain the list of all open file
desriptors so that something akin to fdwalk might be used to close all open
descriptors > fileno(stderr).
all i can think now is
3.upto(65536){|fd| IO::new(fd).close rescue nil}
which is incredibly expensive!
you could set the close on exec flag of all of them too - but getting the list
of all open fds is just as hard... ;-(
i've thought of tracking calls to open by supplanting ruby's File#open, but i
am using every extension which do their own opening too so this is out...
ideas?
cheers.
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================
created) in some code i had written that is caused by forking with open file
descriptors followed by a close/unlink in the parent. the child never uses
the file and so it's not really an 'error' - but on nfs this will cause a
sillyname to appear (.nfsxxxxxxxx) and remain until the child exits which, in
this case, can be up to five days later and i have dozens of these guys
cluttering up my directories since this code runs on dozens of machine
simoutaneously.
i'm wondering - is there some way in ruby to obtain the list of all open file
desriptors so that something akin to fdwalk might be used to close all open
descriptors > fileno(stderr).
all i can think now is
3.upto(65536){|fd| IO::new(fd).close rescue nil}
which is incredibly expensive!
you could set the close on exec flag of all of them too - but getting the list
of all open fds is just as hard... ;-(
i've thought of tracking calls to open by supplanting ruby's File#open, but i
am using every extension which do their own opening too so this is out...
ideas?
cheers.
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================