DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 56GEsbWk3154032 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 56GEsbWk3154032 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=QOGAqiFJ X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 300B7385780D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1752677676; bh=RcJAGR32BQ69Q6uV0ncxNFk1P8GZb5fORuulcI1Lajs=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=QOGAqiFJRICfmP73ZsdhveS6UJUPk+wvTxL/oEMG1SpZOvfpjGr0gt4WL5DXqP4b5 Uyv153BFSythzBZ8+oO3x8ymERV8uZaSSC7ZwanP93tZM7Rvbj1TPIwka3u5NRHqLL h3E9oKiFG2EYPH56zRX7n0AVxX9d7IC5gkRoJHjw= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F38343857B90 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F38343857B90 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1752677566; cv=none; b=BDJp8owhBp3QvApOx02Z/9I/g0J5FRPTz0HPikoAS9pAupI7r5IGqqCyk+VdhMj3nHGDzfQglmyCwuc4U+Max7ealOHiSDjwA1tZtK85t2Kr63htH5mfa75NutUZ5FIUahb+j20aFBf1D7hrpXAMCENj9VYtR7UKy4k21XPDRLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1752677566; c=relaxed/simple; bh=O8Ng51FSHirOnBU590VY6CbL3xGW1dAcpzeMv6MGnD8=; h=Date:From:To:Subject:Message-Id:Mime-Version:DKIM-Signature; b=U/Smx8QYcsdnHn4Xu1AFlMn84YCEMr1cUAjU9NmkmlyQQtNHzMSJ5JJGNzm32wNt53FbuumGExU9L4fM8lPXxYZDToFkhFCo9LpeUXfFcycSKOmULp7tGJiJxUHZZUN5aKb4egbid9EABO7PpussWtuZsK6IFpv0RFfopeGSejU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F38343857B90 Date: Wed, 16 Jul 2025 23:52:36 +0900 To: cygwin AT cygwin DOT com Subject: Re: Calling system() in multi-threads. Message-Id: <20250716235236.96055ec145d9a0528b50c357@nifty.ne.jp> In-Reply-To: <20250618203127.71ac180de11230a9a6055185@nifty.ne.jp> References: <20250617215411 DOT ebf69d1c18b55191a1b76c01 AT nifty DOT ne DOT jp> <20250618203127 DOT 71ac180de11230a9a6055185 AT nifty DOT ne DOT jp> 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 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Takashi Yano via Cygwin Reply-To: Takashi Yano Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Hi Corinna, On Wed, 18 Jun 2025 20:31:27 +0900 Takashi Yano wrote: > 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. Do you have any idea? -- Takashi Yano -- 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