This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
bug in dup2
- From: Eric Blake <ebb9 at byu dot net>
- To: cygwin-patches at cygwin dot com
- Date: Tue, 21 Jul 2009 06:09:12 -0600
- Subject: bug in dup2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
POSIX requires dup2(1,1) to return 1 (if stdout is open), not 0. I wonder
how long that bug has been present? And the STC:
#include <unistd.h>
int main() { return dup2 (1, 1); }
2009-07-21 Eric Blake <ebb9@byu.net>
* dtable.cc (dup2): Correct return value for no-op.
- --
Don't work too hard, make some time for fun as well!
Eric Blake ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEUEARECAAYFAkplr+gACgkQ84KuGfSFAYBSRwCXVTmu0J1jhB22KZLl7kVPEtL2
8QCghsc7m0X7YsfqJDEHT3NLgRu23Bs=
=W7zw
-----END PGP SIGNATURE-----
Index: dtable.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dtable.cc,v
retrieving revision 1.199
diff -u -p -r1.199 dtable.cc
--- dtable.cc 6 Jul 2009 15:11:30 -0000 1.199
+++ dtable.cc 21 Jul 2009 12:07:48 -0000
@@ -621,7 +621,7 @@ dtable::dup2 (int oldfd, int newfd)
if (newfd == oldfd)
{
- res = 0;
+ res = newfd;
goto done;
}