Calling system() in multi-threads.
Corinna Vinschen
corinna-cygwin@cygwin.com
Fri Jul 18 09:10:14 GMT 2025
On Jul 18 17:41, Takashi Yano via Cygwin wrote:
> On Fri, 18 Jul 2025 09:51:11 +0200
> Corinna Vinschen via Cygwin <cygwin@cygwin.com> wrote:
> > Yes, that's what I meant with my above paragraph, i.e.
> >
> > > > > > I checked the sources and I don't see any dependency to ch_spawn
> > > > > > from a spawning process, in contrast to an exec'ing process. That
> > > > > > doesn't mean there is none, just that I didn't find any.
> >
> > These external dependencies *should* only be of interest when performing
> > an execve, but not when performing a spawnve.
>
> So, the previous patch might not correct.
> The following makes more sense, I suppose.
>
> diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
> index cb58b6eed..56fca6e45 100644
> --- a/winsup/cygwin/spawn.cc
> +++ b/winsup/cygwin/spawn.cc
> @@ -944,6 +944,7 @@ spawnve (int mode, const char *path, const char *const *argv,
> int ret;
>
> syscall_printf ("spawnve (%s, %s, %p)", path, argv[0], envp);
> + child_info_spawn ch_spawn_local;
>
> if (!envp)
> envp = empty_env;
> @@ -961,7 +962,7 @@ spawnve (int mode, const char *path, const char *const *argv,
> case _P_WAIT:
> case _P_DETACH:
> case _P_SYSTEM:
> - ret = ch_spawn.worker (path, argv, envp, mode);
> + ret = ch_spawn_local.worker (path, argv, envp, mode);
> break;
> default:
> set_errno (EINVAL);
Yep, indeed.
More information about the Cygwin
mailing list