Re: Compiling problem on AIX 4.2.1 with gcc

From: Duane Wessels <wessels@dont-contact.us>
Date: Tue, 20 Apr 1999 16:45:21 -0600

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