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.y...@nifty.ne.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