From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18929 invoked by alias); 10 Mar 2017 20:10:45 -0000 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 Received: (qmail 18790 invoked by uid 89); 10 Mar 2017 20:10:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-101.7 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1616, died X-HELO: drew.franken.de Received: from mail-n.franken.de (HELO drew.franken.de) (193.175.24.27) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Mar 2017 20:10:38 +0000 Received: from aqua.hirmke.de (aquarius.franken.de [193.175.24.89]) (Authenticated sender: aquarius) by mail-n.franken.de (Postfix) with ESMTPSA id A272C721E281A for ; Fri, 10 Mar 2017 21:10:36 +0100 (CET) Received: from calimero.vinschen.de (calimero.vinschen.de [192.168.129.6]) by aqua.hirmke.de (Postfix) with ESMTP id 1D1B35E019B for ; Fri, 10 Mar 2017 21:10:36 +0100 (CET) Received: by calimero.vinschen.de (Postfix, from userid 500) id 1B831A805A4; Fri, 10 Mar 2017 21:10:36 +0100 (CET) Date: Fri, 10 Mar 2017 20:10:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: fork() fails if it is called recursively from a child thread. Message-ID: <20170310201036.GA18927@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <20170309203959.1e7e32d20bf7ec06c705d3ba@nifty.ne.jp> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="YiEDa0DAkWCtVeE4" Content-Disposition: inline In-Reply-To: <20170309203959.1e7e32d20bf7ec06c705d3ba@nifty.ne.jp> User-Agent: Mutt/1.7.1 (2016-10-04) X-SW-Source: 2017-03/txt/msg00133.txt.bz2 --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1616 Hi, On Mar 9 20:39, Takashi Yano wrote: > Hello, >=20 > I found fork() fails if it is called recursively from a child thread. >=20 > Simple test case, attached (fk.c), reproduces this problem. >=20 > Expected result: > Parent 0 [22034] exit. > Child 0 [22036] works. > Parent 1 [22036] exit. > Child 1 [22038] works. > Parent 2 [22038] exit. > Child 2 [22039] works. > Parent 3 [22039] exit. > Child 3 [22040] works. > Parent 4 [22040] exit. > Child 4 [22041] works. >=20 > Result in cygwin 2.7.0: > Child 0 [4668] works. > Parent 0 [7188] exit. > 0 [main] a 4668 fork: child -1 - forked process 8456 died unexpecte= dly, retry 0, exit code 0xC0000142, errno 11 > fork(): Resource temporarily unavailable >=20 > Strictly speaking, the test case is not safe because it calls functions > which are not async-signal-safe from forked child process, i.e. printf() > and perror(), in spite of multi-thread. However the same happens even > without printf() and perror(). >=20 > This is the cause of which iperf 2.0.5 with option -s -D fails to start > as daemon. Thanks for the report and especially the testcase. It was a tricky problem to debug so it took me a while, but I think I got it now. I uploaded new developer snapshots to https://cygwin.com/snapshots/ Please give them a try. I'd be also interested if that fixes the iperf problem. Can you check? There's always a chance that this uncovers another problem hidden under this one... Thanks, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --YiEDa0DAkWCtVeE4 Content-Type: application/pgp-signature; name="signature.asc" Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYwwg7AAoJEPU2Bp2uRE+gaq4P/2eCe4+BUhC8aTBtXUDTBmtl 4cHlLZPI97Zpiacq8TQ6ZaEvNW6NYtM49t1P6e1qm5bKeXkALeORVkCvCiPsZ1Cn RhyGGrTJL6X9abNFhNrJmKl9PMEbcTDsXQ9DoW1TpWHXiFhnNHy+8v3hE3XpAnXp lZUvm/SKlRZgAZPwZ0U/umJiuN1yUBKMqen8WbN67PXQWVTdNTPB10doe7tuYrjD OpEij52TuO97LLD2EKKfNoM+mSWj/R28QICqgJAucnW1afawjVga2NndrfFOY5YX xIEDbhPkdCe8PWco5mbJXGqr/QKr6TJTQ5tYompSWULEM4CtJhC4CT6g0i3XAnYX Swfu/sXgKMPCdLweRwPojFvBKB0xbDe5QKlC3lsHHg6RzQ3xtIZ7DwPYM9poh+RR 7vvhhYownjeIHtFOnfxR5yCC6Ozj9q6Ut/8vjMizvj7nzNyzk/7HJgYuHAMaTuH9 EiGz6Bs0Z+/rG8EqsYqpm1Qz+boGh4i60Z1z4vtxNCZPMjYPrLEwdGnqq4U5eBHT gofAIhTKATmMsUU1FQv5EIUkDY0Cu634frI2d6Ooc4Oq4Vc96AGjhUjXy5ZGLG3b lHWGRzX9rfvsXAWJOhBtFZF4FHlUA6u9XV9qkzLQNDcgU39NCKUKh0Mcp3jreh/T qYG8zyKphuQqBsflVmKZ =JMlZ -----END PGP SIGNATURE----- --YiEDa0DAkWCtVeE4--