www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/06/18/07:32:11

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 55IBWAQI1009684
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 55IBWAQI1009684
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.2 sourceware.org E5F883852760
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E5F883852760
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750246291; cv=none;
b=T1chwjyvFdsF0ULkJsuFMiys7rzujqk49zX9gsp36WzBoOiL+OxCRgaHTgVSeVlD26uwnksE8nxYnIaSgIr+/mDq8T9bIF8Sq8aO0dn24iT+Ki1dkdz+K3hAYcrGOpDRRLn+Q3iks7dCT7W+H0rXqLnwEEOVDPXWq9+A6zDjaK0=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1750246291; c=relaxed/simple;
bh=R/6Nad2Fhk7q8zRi2oVl0rR1Rnrl1+pKZvva9/ecXdg=;
h=Date:From:To:Subject:Message-Id:Mime-Version:DKIM-Signature;
b=tCO/j+iFSclb9AAKQuH2QWiZg9/z5h8gFmO+lF6t049bSXWXdfb4wM9x37ED/87IuydX2yaWFC6PIvqS7/9IgHyD7G/4i7edMmzuTkYSoK60PisBh6QwhAy9+Py+GuGrOyvGEJVvEMLTnT8GGELIUIpIckthWerUfQKlroAflO0=
ARC-Authentication-Results: i=1; server2.sourceware.org
Date: Wed, 18 Jun 2025 20:31:27 +0900
To: cygwin AT cygwin DOT com
Subject: Re: Calling system() in multi-threads.
Message-Id: <20250618203127.71ac180de11230a9a6055185@nifty.ne.jp>
In-Reply-To: <eb7786ee-dc7a-4689-9d17-b842e581d7c7@maxrnd.com>
References: <20250617215411 DOT ebf69d1c18b55191a1b76c01 AT nifty DOT ne DOT jp>
<eb7786ee-dc7a-4689-9d17-b842e581d7c7 AT maxrnd DOT com>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Mime-Version: 1.0
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
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>
From: Takashi Yano via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
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 Tue, 17 Jun 2025 15:42:26 -0700
Mark Geisert wrote:
> Hi Takashi,
> 
> On 6/17/2025 5:54 AM, Takashi Yano via Cygwin wrote:
> > Hi,
> > 
> > If system() is called in parallel in threads, system()
> > fails with exit code 127.
> > 
> > Just compile pthread_system.c attached and run.
> > 
> > I believe system() is multi-thread safe so the STC
> > should work.
> 
> I regret to inform that system() is not currently MT-safe.  I discovered 
> this a few years ago when porting YAFU (Yet Another Factoring Utility).
> 
> I ended up supplying a wrapper that serialized the system() call itself 
> but allowed multiple wrappers (and thus child processes) to be running 
> at the same time.  I never got around to supplying a fix for Cygwin. 
> I've attached the code.
> HTH somehow,

Thanks for the information. I guess the cause is that accessing
child_info_spawn NO_COPY ch_spawn;
in spwan.cc conflicts with other threads. I wonder ch_spawn should
be thread-specific. Or should be guarded by lock.

-- 
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