annotate doc/posix-functions/symlinkat.texi @ 15326:52719068f9c2

pipe, pipe2: don't corrupt fd on error I noticed a potential subtle double-close bug in libvirt. There, a common idiom is to initialize an int fd[2]={-1,-1}, then have multiple error paths goto common cleanup code. In the cleanup code, the fds are closed if they are not already -1; this works if the error label is reached before the pipe call, or after pipe succeeds, but if it was the pipe call itself that jumped to the error label, then it is relying on failed pipe() not altering the values already in fd array prior to the failure. Our pipe2 replacement violated this assumption, and could leave a non-negative value in the array, which in turn would let libvirt close an already-closed fd, possibly nuking an unrelated fd opened by another thread that happened to get the same value. As a result, I raised a POSIX issue regarding the behavior of pipe on failure: http://austingroupbugs.net/view.php?id=467 Using that test program, I learned that most systems leave fd unchanged on error, but that mingw always assigns -1 into the array. This fixes the mingw pipe() replacement, as well as the gnulib pipe2() replacement. I don't know of any race-free way to work around a cygwin crash: http://cygwin.com/ml/cygwin/2011-06/msg00328.html - we could always open() and then close() two fds to guess whether two spare fd still remain before calling pipe(), but that is racy. * lib/pipe.c (pipe): Leave fd unchanged on error. * lib/pipe2.c (pipe2): Likewise. * doc/posix-functions/pipe.texi (pipe): Document cygwin issue. * doc/glibc-functions/pipe2.texi (pipe2): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
author Eric Blake <eblake@redhat.com>
date Wed, 29 Jun 2011 15:46:50 -0600
parents ac911e0db006
children 847372253549
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10880
b1d6a7b9222f Document functions that have been added to POSIX:2008.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 @node symlinkat
b1d6a7b9222f Document functions that have been added to POSIX:2008.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 @section @code{symlinkat}
b1d6a7b9222f Document functions that have been added to POSIX:2008.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 @findex symlinkat
b1d6a7b9222f Document functions that have been added to POSIX:2008.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
13549
bb0ceefd22dc avoid some overlong lines from posix urls, etc.
Karl Berry <karl@freefriends.org>
parents: 12486
diff changeset
5 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/symlinkat.html}
10880
b1d6a7b9222f Document functions that have been added to POSIX:2008.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
11956
55cb5282dd84 symlinkat: new module
Eric Blake <ebb9@byu.net>
parents: 10883
diff changeset
7 Gnulib module: symlinkat
10880
b1d6a7b9222f Document functions that have been added to POSIX:2008.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
b1d6a7b9222f Document functions that have been added to POSIX:2008.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 Portability problems fixed by Gnulib:
b1d6a7b9222f Document functions that have been added to POSIX:2008.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 @itemize
b1d6a7b9222f Document functions that have been added to POSIX:2008.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 @item
b1d6a7b9222f Document functions that have been added to POSIX:2008.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 This function is missing on some platforms:
13892
ac911e0db006 Update for NetBSD 5.0.
Bruno Haible <bruno@clisp.org>
parents: 13890
diff changeset
13 glibc 2.3.6, MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX
10883
e578654f58d3 Update doc for cygwin 1.7.
Eric Blake <ebb9@byu.net>
parents: 10880
diff changeset
14 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, Interix 3.5, BeOS.
12129
8e8f0292e99f doc: tweak *at function documentation
Eric Blake <ebb9@byu.net>
parents: 11956
diff changeset
15 But the replacement function is not safe to be used in libraries and is not multithread-safe.
12486
8d19393d7abe unistd: work around cygwin bug
Eric Blake <ebb9@byu.net>
parents: 12129
diff changeset
16 @item
8d19393d7abe unistd: work around cygwin bug
Eric Blake <ebb9@byu.net>
parents: 12129
diff changeset
17 Some platforms declare this function in @code{stdio.h} instead of
8d19393d7abe unistd: work around cygwin bug
Eric Blake <ebb9@byu.net>
parents: 12129
diff changeset
18 @code{unistd.h}:
8d19393d7abe unistd: work around cygwin bug
Eric Blake <ebb9@byu.net>
parents: 12129
diff changeset
19 Cygwin 1.7.1.
10880
b1d6a7b9222f Document functions that have been added to POSIX:2008.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 @end itemize
11956
55cb5282dd84 symlinkat: new module
Eric Blake <ebb9@byu.net>
parents: 10883
diff changeset
21
55cb5282dd84 symlinkat: new module
Eric Blake <ebb9@byu.net>
parents: 10883
diff changeset
22 Portability problems not fixed by Gnulib:
55cb5282dd84 symlinkat: new module
Eric Blake <ebb9@byu.net>
parents: 10883
diff changeset
23 @itemize
55cb5282dd84 symlinkat: new module
Eric Blake <ebb9@byu.net>
parents: 10883
diff changeset
24 @item
55cb5282dd84 symlinkat: new module
Eric Blake <ebb9@byu.net>
parents: 10883
diff changeset
25 This function always fails with @samp{ENOSYS} on platforms that don't
55cb5282dd84 symlinkat: new module
Eric Blake <ebb9@byu.net>
parents: 10883
diff changeset
26 support symlinks:
55cb5282dd84 symlinkat: new module
Eric Blake <ebb9@byu.net>
parents: 10883
diff changeset
27 mingw
55cb5282dd84 symlinkat: new module
Eric Blake <ebb9@byu.net>
parents: 10883
diff changeset
28 @end itemize