[PATCH] Core: prefer ioctl(FIOCLEX) over fcntl(FD_CLOEXEC)

Maxim Dounin mdounin at mdounin.ru
Thu Oct 25 15:34:46 UTC 2012


On Thu, Oct 25, 2012 at 03:46:47PM +0200, Ben Noordhuis wrote:

> Use ioctl(FIOCLEX) to set the close-on-exec flag on platforms where it makes
> sense: Linux, Darwin, the BSDs, *not* Solaris.
> ioctl(FIOCLEX) is generally slightly faster than fcntl(FD_CLOEXEC), on the
> order of 3-4%.

While ioctl(FIOCLEX) may be a bit faster, fcntl(FD_CLOEXEC) is only 
used on rarely executed code paths.  Given the fact that fcntl() 
aproach is much more portable it doesn't make sense to change 
anything here.


Maxim Dounin

More information about the nginx-devel mailing list