From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-05.nifty.com (conssluserg-05.nifty.com [210.131.2.90]) by sourceware.org (Postfix) with ESMTPS id 57F8E385840D for ; Fri, 14 Jan 2022 00:22:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 57F8E385840D Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp Received: from Express5800-S70 (ae233132.dynamic.ppp.asahi-net.or.jp [14.3.233.132]) (authenticated) by conssluserg-05.nifty.com with ESMTP id 20E0MK7A013786 for ; Fri, 14 Jan 2022 09:22:20 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com 20E0MK7A013786 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1642119740; bh=K6uPpovD9TePaQbr4Jck5HEOrKpmCYkoKpguMG49mbs=; h=Date:From:To:Subject:In-Reply-To:References:From; b=ktRPn5RvJDL65UXx6PC9gFXIFF6d60ZDMTMuCTc/jh5P1h1Ig38MN/n1UpAwW7WRJ 3Ct+tS/fbxRsZjen8YIoe6BPx8tsvqhjd6ynL1nuaiwINNwH3PwBrbHWYxe3pkr2po v82BpBcPRuujL+YKCkAlr0FlsCH+H7UZI6EPkci/eWOcw1La750JiE3SUGJE2uVaqz GSFCvNvAtNHKZb9rgV08TqS0axYgy2sqq2CwXPfSJ9mbP5QJh4NQ7Id1vR8/uP3GGK Y1HavK1vxGZOwcBG9/w+kcXMDykIMyx8Gowi5wfgMu0vBzGfQu9SHvTsPGifMTZX93 FpiwaZlEaN8IQ== X-Nifty-SrcIP: [14.3.233.132] Date: Fri, 14 Jan 2022 09:22:27 +0900 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6 Message-Id: <20220114092227.0beae61df0394925212fd6c4@nifty.ne.jp> In-Reply-To: <12affe5c-6f2c-ee89-7e21-ac1b91c3d58e@maxrnd.com> References: <9b20c19a-b075-1dd3-d9f3-8cf53c51b1e5@gmail.com> <20220114085227.c044e8735fb5d92e341d0b84@nifty.ne.jp> <12affe5c-6f2c-ee89-7e21-ac1b91c3d58e@maxrnd.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2022 00:22:51 -0000 On Thu, 13 Jan 2022 16:11:04 -0800 Mark Geisert wrote: > Takashi Yano wrote: > > On Wed, 12 Jan 2022 07:41:41 +0100 > > Marco Atzeri wrote: > >> On 12.01.2022 07:27, Jay K wrote: > >>> Ok, here is a small demonstration of the problem. > >>> > >>> #include > >>> #include > >>> #include > >>> > >>> unsigned __stdcall thread(void* p) > >>> { > >>> unsigned i; > >>> for (i = 0; i < 100; ++i) > >>> system("./a.exe"); > >>> return 0; > >>> } > >>> > >>> int main() > >>> { > >>> unsigned i; > >>> HANDLE threads[100] = {0}; > >>> FILE* f = fopen("a.c", "w"); > >>> fprintf(f, "int main() { return 0; }\n"); > >>> fclose(f); > >> > >> > >> so you are mixing Cygwin and Windows calls ? > >> That is looking for trouble. > >> > >> Or it is a tentative to produce a test case ? > > > > I found that the same happens even with pthread rather than > > win32 thread functions. > > > > #include > > #include > > > > void *thread(void *p) > > { > > system("true"); > > return NULL; > > } > > > > int main() > > { > > int i; > > pthread_t threads[2]; > > > > for (i = 0; i < 2; i++) > > pthread_create(&threads[i], NULL, thread, NULL); > > > > for (i = 0; i < 2; i++) > > pthread_join(threads[i], NULL); > > > > return 0; > > } > > > > Executing above code results in hang with message: > > 0 [waitproc] a 786 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6 > > > > POSIX does not require system() to be thread-safe. On Cygwin, it isn't. When I > ran into this a while back, I implemented an application wrapper around system() > to serialize calls. It's tricky because you want to serialize just the mechanism > of system(), not the programs that the multiple system()s call. Ah, indeed. https://pubs.opengroup.org/onlinepubs/9699919799/functions/system.html says: "The system() function need not be thread-safe." while Linux's system() is MT-safe. Thanks. -- Takashi Yano