poll tests: Avoid test failure on BSD and Solaris systems.
[gnulib.git] / doc / posix-functions / fopen.texi
blob401367bcb63c3c2ec86c8fd4b8e3374e0ff7877a
1 @node fopen
2 @section @code{fopen}
3 @findex fopen
5 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html}
7 Gnulib module: fopen or fopen-gnu
9 Portability problems fixed by either Gnulib module @code{fopen} or @code{fopen-gnu}:
10 @itemize
11 @item
12 This function does not fail when the file name argument ends in a slash
13 and (without the slash) names a nonexistent file or a file that is not a
14 directory, on some platforms:
15 HP-UX 11.00, AIX 7.1, Solaris 9.
16 @item
17 On platforms where @code{off_t} is a 32-bit type, @code{fopen} may not work
18 correctly with files larger than 2 GB@.  (Cf. @code{AC_SYS_LARGEFILE}.)
19 @item
20 On Windows platforms (excluding Cygwin), this function does usually not
21 recognize the @file{/dev/null} filename.
22 @end itemize
24 Portability problems fixed by Gnulib module @code{fopen-gnu}:
25 @itemize
26 @item
27 This function does not support the mode character
28 @samp{x} (corresponding to @code{O_EXCL}), introduced in ISO C11,
29 on some platforms:
30 FreeBSD 8.2, NetBSD 6.1, OpenBSD 5.6, Minix 3.2, AIX 6.1, HP-UX 11.31, IRIX 6.5, Solaris 11.3, Cygwin 1.7.16 (2012), mingw, MSVC 14.
31 @item
32 This function does not support the mode character
33 @samp{e} (corresponding to @code{O_CLOEXEC}),
34 introduced into a future POSIX revision through
35 @url{https://www.austingroupbugs.net/view.php?id=411}, on some platforms:
36 glibc 2.6, Mac OS X 10.13, FreeBSD 9.0, NetBSD 5.1, OpenBSD 5.6, Minix 3.2, AIX 7.2, HP-UX 11.31, IRIX 6.5, Solaris 11.3, Cygwin 1.7.16 (2012), mingw, MSVC 14.
37 @end itemize
39 Portability problems not fixed by Gnulib:
40 @itemize
41 @item
42 On Windows platforms (excluding Cygwin), this function does not set @code{errno}
43 upon failure.
44 @item
45 On Windows, this function returns a file stream in ``text'' mode by default;
46 this means that it translates @code{'\n'} to CR/LF by default.  Use the
47 @code{"b"} flag if you need reliable binary I/O.
48 @item
49 On Windows platforms (excluding Cygwin), this function fails to open
50 directories for reading.  Such streams have implementation-defined
51 semantics on other platforms.  To avoid directory streams with a
52 consistent error message, use @code{fstat} after @code{open} and
53 @code{fdopen}, rather than @code{fopen} and @code{fileno}.
54 @end itemize