delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/01/13/19:23:07

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
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
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 <takashi DOT yano AT nifty DOT ne DOT jp>
To: cygwin AT cygwin DOT 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: <MWHPR1401MB1951673B53610E3D45F15235E6529 AT MWHPR1401MB1951 DOT namprd14 DOT prod DOT outlook DOT com>
<MWHPR1401MB1951AD1FD95142752195EF0DE6529 AT MWHPR1401MB1951 DOT namprd14 DOT prod DOT outlook DOT com>
<MWHPR1401MB195104100F4D135F78351B86E6529 AT MWHPR1401MB1951 DOT namprd14 DOT prod DOT outlook DOT com>
<9b20c19a-b075-1dd3-d9f3-8cf53c51b1e5 AT gmail DOT com>
<20220114085227 DOT c044e8735fb5d92e341d0b84 AT nifty DOT ne DOT jp>
<12affe5c-6f2c-ee89-7e21-ac1b91c3d58e AT maxrnd DOT com>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Mime-Version: 1.0
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 AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

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 <stdlib.h>
> >>> #include <stdio.h>
> >>> #include <windows.h>
> >>>
> >>> 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 <stdlib.h>
> > #include <pthread.h>
> > 
> > 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 <takashi DOT yano AT nifty DOT ne DOT jp>

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019