bug-gnulib
[Top][All Lists]
Advanced

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

Re: O_CLOEXEC support


From: Eric Blake
Subject: Re: O_CLOEXEC support
Date: Fri, 21 Aug 2009 05:53:04 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.22) Gecko/20090605 Thunderbird/2.0.0.22 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Paolo Bonzini on 8/21/2009 1:34 AM:
>> (or, is mingw subject to a compile-time maximum of open fds
>> where we can just return EMFILE up front?).

EMFILE is more appropriate that EBADF; POSIX states this for fcntl:

 [EMFILE]
    The argument cmd is F_DUPFD or F_DUPFD_CLOEXEC and all file
descriptors available to the process are currently open, or no file
descriptors greater than or equal to arg are available.

> 
> The maximum valid file descriptor number for MSVCRT (and hence mingw) is
> 2047:

Makes sense.  Based on stack usage for one iteration, that won't use more
than a couple pages of stack, if someone ever tries to use an fd that large.

> and above the limit dup2 fails with EBADF.  I didn't find any
> documentation but the limit is already quite high and so it is unlikely
> to increase: for Linux, the limit is 1024 (and it also fails with EBADF).

Well, regardless of what POSIX recommends for this failure case, I'm
comfortable returning EBADF if that's what the recursion ended with.

> You can compute this at configure time and use a bitmask too, but I
> think it is overkill.

Agreed.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqOiqAACgkQ84KuGfSFAYAClgCgkcv/v28pcA3ZMxroVrUHymFg
UkcAnR5WVwb7rvEMALSRZ+L/LZv9rhZn
=KKXs
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]