Re: socket(2) guarantee to return the lowest-available file descriptor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Yubin

On 11 September 2017 at 04:56, Yubin Ruan <ablacktshirt@xxxxxxxxx> wrote:
> Hi,
> Is there any guarantee that socket(2) will return the lowest-available
> file descriptor?
>
> I note in the man page that open(2) has that guarantee, conforming to
> POSIX, but nothing about that has been add to socket(2). As socket(2)
> is said to be conforming to POSIX in the main page, which implies that
> guarantee, should we add that to the man page?

Yes, I've added the same text to socket(2). Thanks for the report.

Cheers,

Michael

POSIX.1:
2.14
File Descriptor Allocation
All functions that open one or more file descriptors shall, unless
specified otherwise, atomically
allocate the lowest numbered available (that is, not already open in
the calling process) file
descriptor at the time of each allocation. Where a single function
allocates two file descriptors
(for example, pipe( ) or socketpair( )), the allocations may be
independent and therefore
applications should not expect them to have adjacent values or depend
on which has the higher
value.

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux