poll tests: Avoid test failure on BSD and Solaris systems.
[gnulib.git] / doc / posix-functions / unlinkat.texi
blob0740edb0f9d7271ab0d7a2c35e03e063277d5696
1 @node unlinkat
2 @section @code{unlinkat}
3 @findex unlinkat
5 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html}
7 Gnulib module: unlinkat
9 Portability problems fixed by Gnulib:
10 @itemize
11 @item
12 This function is missing on some platforms:
13 glibc 2.3.6, Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8,
14 AIX 5.1, HP-UX 11, IRIX 6.5, Cygwin 1.5.x, mingw, MSVC 14.
15 But the replacement function is not safe to be used in libraries and is not multithread-safe.
16 @item
17 This function is declared in @code{<fcntl.h>}, not in @code{<unistd.h>},
18 on some platforms:
19 Cygwin 1.7.1, Android 4.3.
20 @item
21 On Mac OS X 10.10, in a writable HFS mount, @code{unlinkat(fd, "..", 0)} succeeds
22 without doing anything.
23 @item
24 Some systems mistakenly succeed on @code{unlinkat(fd,"file/",flag)}:
25 GNU/Hurd, Solaris 9.
26 @end itemize
28 Portability problems not fixed by Gnulib:
29 @itemize
30 @item
31 When @code{unlinkat(fd,name,AT_REMOVEDIR)} fails because the specified
32 directory is not empty, the @code{errno} value is system dependent.
33 @item
34 POSIX requires that @code{unlinkdir(fd,"link-to-empty/",AT_REMOVEDIR)}
35 remove @file{empty} and leave @file{link-to-empty} as a dangling
36 symlink.  This is counter-intuitive, so some systems fail with
37 @code{ENOTDIR} instead:
38 glibc
39 @item
40 Some systems allow a superuser to unlink directories, even though this
41 can cause file system corruption.  The error given if a process is not
42 permitted to unlink directories varies across implementations; it is
43 not always the POSIX value of @code{EPERM}.  Meanwhile, if a process
44 has the ability to unlink directories, POSIX requires that
45 @code{unlinkat(fd,"symlink-to-dir/",0)} remove @file{dir} and leave
46 @file{symlink-to-dir} dangling; this behavior is counter-intuitive.
47 The gnulib module @code{unlinkdir} can help determine whether code must be
48 cautious of unlinking directories.
49 @item
50 Removing an open file is non-portable: On Unix this allows the programs that
51 have the file already open to continue working with it; the file's storage
52 is only freed when the no process has the file open any more.  On Windows,
53 the attempt to remove an open file fails.
54 @end itemize