From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from m0.truegem.net (m0.truegem.net [69.55.228.47]) by sourceware.org (Postfix) with ESMTPS id 53366385840D for ; Fri, 14 Jan 2022 00:11:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 53366385840D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maxrnd.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=maxrnd.com Received: (from daemon@localhost) by m0.truegem.net (8.12.11/8.12.11) id 20E0BAhi027309 for ; Thu, 13 Jan 2022 16:11:10 -0800 (PST) (envelope-from mark@maxrnd.com) Received: from 162-235-43-67.lightspeed.irvnca.sbcglobal.net(162.235.43.67), claiming to be "[192.168.1.100]" via SMTP by m0.truegem.net, id smtpdoSgsLe; Thu Jan 13 16:11:04 2022 Subject: Re: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6 To: cygwin@cygwin.com References: <9b20c19a-b075-1dd3-d9f3-8cf53c51b1e5@gmail.com> <20220114085227.c044e8735fb5d92e341d0b84@nifty.ne.jp> From: Mark Geisert Message-ID: <12affe5c-6f2c-ee89-7e21-ac1b91c3d58e@maxrnd.com> Date: Thu, 13 Jan 2022 16:11:04 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.4 MIME-Version: 1.0 In-Reply-To: <20220114085227.c044e8735fb5d92e341d0b84@nifty.ne.jp> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, NICE_REPLY_A, SPF_HELO_NONE, SPF_NONE, 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:11:13 -0000 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. ..mark