unlinkat ¶POSIX specification:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/unlinkat.html
Portability problems fixed by Gnulib:
<fcntl.h>, not in <unistd.h>,
on some platforms:
Cygwin 1.7.1, Android 4.3.
unlinkat(fd, "..", 0) succeeds
without doing anything.
unlinkat(fd,"file/",flag):
GNU/Hurd, Solaris 9.
Portability problems not fixed by Gnulib:
unlinkat(fd,name,AT_REMOVEDIR) fails because the specified
directory is not empty, the errno value is system dependent.
unlinkdir(fd,"link-to-empty/",AT_REMOVEDIR)
remove empty and leave link-to-empty as a dangling
symlink. This is counter-intuitive, so some systems fail with
ENOTDIR instead:
glibc
EPERM. Meanwhile, if a process
has the ability to unlink directories, POSIX requires that
unlinkat(fd,"symlink-to-dir/",0) remove dir and leave
symlink-to-dir dangling; this behavior is counter-intuitive.
The gnulib module unlinkdir can help determine whether code must be
cautious of unlinking directories.