X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_FD,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Message-ID: <4E0B9959.6060903@redhat.com> Date: Wed, 29 Jun 2011 15:30:01 -0600 From: Eric Blake User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10 MIME-Version: 1.0 To: cygwin Subject: bug in pipe() and pipe2() OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig3949EC4F562740A3C5F81E2B" X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --------------enig3949EC4F562740A3C5F81E2B Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I was testing the behavior when pipe() fails, in order to propose an update to POSIX wording: http://austingroupbugs.net/view.php?id=3D467 However, cygwin's pipe implementation dumps core when it runs out of fds, so I could not definitively state whether cygwin properly leaves the fd array unchanged on error, the way Linux does. According to a gdb run and while using stock 1.7.9 cygwin1.dll, the crash is in fhandler_pipe::create(). #define _POSIX_C_SOURCE 200811L #include #include #include #include int main (int argc, char **argv) { int i =3D 0; while (1) { int fd[2] =3D {-2,-3}; int err =3D pipe(fd); if (err) { printf ("iteration %d, pipe returned %d errno %d %s, fds %d %d\n", i, err, errno, strerror(errno), fd[0], fd[1]); break; } i++; } return 0; } Expected behavior is EMFILE and fd unchanged, after however many iterations it takes to reach the ulimit on max fd. --=20 Eric Blake eblake AT redhat DOT com +1-801-349-2682 Libvirt virtualization library http://libvirt.org --------------enig3949EC4F562740A3C5F81E2B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJOC5lZAAoJEKeha0olJ0Nq9p4H/i0CSyHCKNCmu57n9FCk/Y3Z gsQ15Vxj3brofFgG62AiXjRx99ttDKfMr106OOTjlCpasJRf92Wr2BqPU+OxiShD +LNrYVAhZ4v51K3ycAfMi0/TxSaxTXbl9Do3mp+Hv3DFQ7iLW/0KKKdqFCHweF6r hbhiBbzmqEiriZQYFRUmMgB5vTERdZUrgW70+XDj8aAFh2s/X5+p5kh1izjqybXR b8FIwNIB64gkt0qYCZYU/ErLVwqGn0Tu/EGTG/alBC/efpmpqpn29xsPwmXT4qKf xVPxX1FPP1uOswuR+KuJXFJKZoXKahr/z3A1lSj5AX4lXN9x69OFcYc3IunlXo8= =EzQ6 -----END PGP SIGNATURE----- --------------enig3949EC4F562740A3C5F81E2B--