Subject: Re: implementing closeall via a syscall
To: Andrew Brown <email@example.com>
From: Greywolf <firstname.lastname@example.org>
Date: 01/05/2004 12:02:03
Thus spake Andrew Brown ("AB> ") sometime Today...
AB> >solaris has closefrom(), which does the same thing (using /proc if I'm
AB> >not mistaken). So that would be a better name.
Solaris 2.8 and above have (paraphrased):
closefrom(int n): close all fds equal to and above n
fdwalk(int (*fn)(void *, int), void *callback): generate a list of open
file descriptors, passing the pointer to the callback data
as the first arg of fn, and passing the value of the open fd
from the list as the second arg of fn.
I would prefer to see a closem() or closefrom() or whatever apply to
a range of fds as user-defined, i.e. closem(from,to), which closes all
descriptors from "from" to "to", inclusive, as a program might wish to
relocate fds 0, 1, 2 to some other place. closem(from, -1) or
closem(-1,to) is what I envisioned. Unadjustably single-ended ranges
are a major pain, from a programming point of view.
thought: I ain't so damb dumn! | Your brand new kernel just dump core on you
war: Invalid argument | And fsck can't find inode 2
| Don't worry -- be happy...