diff options
| author | Tom Tromey <tromey@redhat.com> | 2013-01-05 19:36:45 -0700 |
|---|---|---|
| committer | Tom Tromey <tromey@redhat.com> | 2013-01-05 19:36:45 -0700 |
| commit | e078a23febca14bc919c5806670479c395e3253e (patch) | |
| tree | e9e4ed91feef744d525264c31974c3ed00146bcd /lib/dup2.c | |
| parent | 63d535c829a930207b64fe733228f15a554644b1 (diff) | |
| parent | 7a2657fa3bedbd977f4e11fe030cb4a210c04ab4 (diff) | |
| download | emacs-e078a23febca14bc919c5806670479c395e3253e.tar.gz | |
merge from trunk
Diffstat (limited to 'lib/dup2.c')
| -rw-r--r-- | lib/dup2.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/dup2.c b/lib/dup2.c index f6d0f1c73c5..9219eb38238 100644 --- a/lib/dup2.c +++ b/lib/dup2.c @@ -1,6 +1,6 @@ /* Duplicate an open file descriptor to a specified file descriptor. - Copyright (C) 1999, 2004-2007, 2009-2012 Free Software Foundation, Inc. + Copyright (C) 1999, 2004-2007, 2009-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -95,7 +95,10 @@ rpl_dup2 (int fd, int desired_fd) # ifdef F_GETFL /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF. On Cygwin 1.5.x, dup2 (1, 1) returns 0. + On Cygwin 1.7.17, dup2 (1, -1) dumps core. On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */ + if (desired_fd < 0) + fd = desired_fd; if (fd == desired_fd) return fcntl (fd, F_GETFL) == -1 ? -1 : fd; # endif |
