Subject: Re: implementing closeall via a syscall
To: Greywolf <>
From: George Peter Staplin <>
List: tech-kern
Date: 01/06/2004 16:20:54
On Mon, 5 Jan 2004, Greywolf wrote:

> Date: Mon, 5 Jan 2004 12:02:03 -0800 (PST)
> From: Greywolf <>
> To: Andrew Brown <>
> Cc: mouss <>,
> Subject: Re: implementing closeall via a syscall
> 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.
> AB>
> AB> uh...where?
> 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.

To me those names are not ideal.  What do you think about closerange() or

Bringing you quality nerdy products since 1981.