From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8804 invoked by alias); 4 Aug 2011 06:00:54 -0000 Received: (qmail 8790 invoked by uid 22791); 4 Aug 2011 06:00:51 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_FD,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-wy0-f171.google.com (HELO mail-wy0-f171.google.com) (74.125.82.171) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Aug 2011 06:00:36 +0000 Received: by wyi11 with SMTP id 11so1400896wyi.2 for ; Wed, 03 Aug 2011 23:00:34 -0700 (PDT) Received: by 10.227.39.14 with SMTP id d14mr347343wbe.33.1312437634719; Wed, 03 Aug 2011 23:00:34 -0700 (PDT) Received: from [109.113.27.32] ([109.113.27.32]) by mx.google.com with ESMTPS id fc2sm1221195wbb.1.2011.08.03.23.00.32 (version=SSLv3 cipher=OTHER); Wed, 03 Aug 2011 23:00:33 -0700 (PDT) Message-ID: <4E3A3582.5020904@gmail.com> Date: Thu, 04 Aug 2011 06:00:00 -0000 From: Marco atzeri User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: odd socketpair() failure References: <4E39D525.5070804@redhat.com> In-Reply-To: <4E39D525.5070804@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2011-08/txt/msg00112.txt.bz2 On 8/4/2011 1:09 AM, Eric Blake wrote: > A while ago, I tested pipe() for EMFILE failures [1]. Well, I repeated > those tests for socketpair() [2], and cygwin is once again the odd man out. > > [1] http://cygwin.com/ml/cygwin/2011-06/msg00328.html > [2] http://austingroupbugs.net/view.php?id=483 > > $ cat foo.c > #define _POSIX_C_SOURCE 200811L > #define __EXTENSIONS__ 1 > #include > #include > #include > #include > #include > #include > #include > #include > int > main (int argc, char **argv) > { > int last; > int fd[2] = {-2,-3}; > int err; > /* Get to an EMFILE condition. */ > while (1) { > int fd = open("/dev/null", O_RDONLY); > if (fd < 0) { > printf ("after fd %d, open failed with errno %d %s\n", > last, errno, strerror(errno)); > break; > } > last = fd; > } > /* Probe behavior */ > err = socketpair(AF_UNIX, SOCK_STREAM, 0, fd); > if (err) > printf ("try 1, socketpair returned %d errno %d %s, fds %d %d\n", > err, errno, strerror(errno), fd[0], fd[1]); > else > printf ("try 1, socketpair succeeded, fds %d %d\n", fd[0], fd[1]); > if (close(last)) > return 1; > err = socketpair(AF_UNIX, SOCK_STREAM, 0, fd); > if (err) > printf ("try 2, socketpair returned %d errno %d %s, fds %d %d\n", > err, errno, strerror(errno), fd[0], fd[1]); > else > printf ("try 2, socketpair succeeded, fds %d %d\n", fd[0], fd[1]); > if (close(0)) > return 1; > err = socketpair(AF_UNIX, SOCK_STREAM, 0, fd); > if (err) > printf ("try 3, socketpair returned %d errno %d %s, fds %d %d\n", > err, errno, strerror(errno), fd[0], fd[1]); > else > printf ("try 3, socketpair succeeded, fds %d %d\n", fd[0], fd[1]); > return 0; > } > $ ./foo > after fd 3199, open failed with errno 24 Too many open files > try 1, socketpair returned -1 errno 24 Too many open files, fds -2 -3 > try 2, socketpair returned -1 errno 24 Too many open files, fds -2 -3 > try 3, socketpair returned -1 errno 24 Too many open files, fds -2 -3 > > But on Linux, try 3 succeeds. Something in cygwin is not quite right on > try 3 - the program explicitly freed two fd slots (0 and 3199), so it > should have plenty of room to create the socketpair without hitting EMFILE. > > Disclaimer: I tested on 1.7.9 rather than the latest snapshot; maybe the > pipe() fix in the meantime also fixed socketpair()? > same result on latest CVS Marco -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple