view doc/posix-functions/dup2.texi @ 17688:0d3cc0db9cb7

dup2, fcntl, fcntl-h: port to AIX 7.1 This fixes some porting problems discovered when testing the latest grep snapshot on AIX 7.1. I don't think if fixes any bugs in grep but it could be important for other applications. * doc/posix-functions/dup2.texi: * doc/posix-functions/fcntl.texi: * doc/posix-headers/fcntl.texi: Document AIX bugs. * lib/fcntl.in.h (O_CLOEXEC, O_NOFOLLOW, O_TTY_INIT) [_AIX]: Define to 0 if outside 'int' range. * m4/dup2.m4 (gl_FUNC_DUP2): * m4/fcntl.m4 (gl_FUNC_FCNTL): Check for getdtablesize. If it's available, test a value just outside its range instead of testing 1000000. When cross-compiling, guess that AIX will fail this improved test.
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 31 May 2014 14:07:57 -0700
parents 7fadcfb1189f
children 587c85f38b58
line wrap: on
line source

@node dup2
@section @code{dup2}
@findex dup2

POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/dup2.html}

Gnulib module: dup2 or dup2-obsolete

Portability problems fixed by either Gnulib module @code{dup2} or @code{dup2-obsolete}:
@itemize
@item
This function always returns 0 for success on some platforms:
mingw, MSVC 9.

@item
This function can hang when duplicating an fd to itself on some platforms:
mingw, MSVC 9.

@item
This function crashes when invoked with invalid arguments on some platforms:
Cygwin 1.7.17, MSVC 9.

@item
This function crashes when invoked with valid arguments on some platforms:
Cygwin 1.7.25.

@item
This function resets the @code{FD_CLOEXEC} flag when duplicating an fd
to itself on some platforms:
Haiku.

@item
This function returns 0 for @code{dup2 (1, 1)} on some platforms:
Cygwin 1.5.x.

@item
This function may return @code{-EBADF} instead of @code{-1} on some platforms:
Linux releases between July 2008 and May 2009 (versions 2.6.27 to 2.6.29).

@item
This function returns @code{EMFILE} instead of @code{EBADF} for
large targets, which interferes with using
@code{dup2(fd,fd)==fd)} as the minimal @code{EBADF} filter:
AIX 7.1, FreeBSD 6.1, Cygwin 1.5.
@end itemize

Portability problems fixed by Gnulib module @code{dup2-obsolete}:
@itemize
@item
This function is missing on some older platforms.
@end itemize

Portability problems not fixed by Gnulib:
@itemize
@end itemize