Chris Wedgwood writes:
>> Hm, instead of a loop, what about a binary search using dup2()
>> starting at some large number like 16384.
>
>Actually, thats a really smart idea... does it work?
yep:
main()
{
int i = 16384;
int j = i;
while (j) {
j >>= 1;
printf("trying %d, j=%d\n", i, j);
if (dup2(0, i) < 0) {
i -= j;
} else {
close(i);
i += j;
}
}
i++;
printf("maxfd = %d\n", i);
}
Duane W.
Received on Tue Jul 29 2003 - 13:15:57 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:05 MST