Messages in this thread | | | Date | Wed, 28 Aug 2002 01:21:45 +0200 | From | DervishD <> | Subject | Re: How can a process easily get a list of all it's open fd? |
| |
Hi Mark :)
>So what's the "right way" to do it?
AFAIK, the for loop, with getdtablesize() instead of 'OPEN_MAX'. I do it that way, but I don't really know if it is the 'right way'(tm).
>I would *love* for there to be an ioctl or some syscall that I could >pass a pointer to an int and a pointer to an int array, and it would >come back telling me how many open fd's I've got, and fill in the >array with those fd's.
The array should be allocated by the kernel, or the syscall won't work as expected ;) If you have 2000 fd open and the array whose address you pass to the ioctl has an smaller size... Anyway, you can call the ioctl a few times ;)
Your proposal seems reasonable (unless there is any other way of doing this portably), but portability will be an issue...
Raúl - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |