in reply to Closing all filehandles associate with an fd

.... you might be able to look at the fd file numbers in /proc/$pid/fd, store them in arrays as they get created.... i.e. as you open a filehandle, get it's fd and store it, so you can delete them later by fd...... i wonder what would happen if you just recursively delete /proc/$pid/fd/* .... i hesitate to try....maybe it would make zombies? with fd's 0,1,, and 2 gone?

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku
  • Comment on Re: Closing all filehandles associate with an fd

Replies are listed 'Best First'.
Re^2: Closing all filehandles associate with an fd
by afoken (Chancellor) on Dec 12, 2009 at 23:47 UTC

    You don't even need the PID, because /proc/self is a symlink to the /proc/$pid directory provided by the kernel, at least on Linux 2.x. The downside is that neither /proc/self nor /proc/$pid exist on all operating systems. And even on systems where a proc filesystem exists, it is not always mounted. Deleting /proc/$pid/fd/$n will probably just fail with a "permission denied" error, simply because it makes no sense.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)