X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76D7A3857350 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1681979761; bh=Nq8FiAQQ2PWaxLqjkT3NYfh7OxLda3IX5lOH9k4hYac=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=yax7zBGnY0P8PFPmccGT1hV8clDKTQ8cgU9lTerj7D1KV9MVMqRwKIQTK/k5Sd3Ot ru5oi8JmSegIWGyRZOBE4CRZ+f66mHsU+d1wMBOSAKzYGyLKN8enrHMAO+lScBfRhK LSUC6QsT+tK0ZtzCXxfE+SojstS49a3dmyia5cU0= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D043A385843E Date: Thu, 20 Apr 2023 10:35:20 +0200 To: gs-cygwin DOT com AT gluelogic DOT com Subject: Re: posix_spawn facility Message-ID: Mail-Followup-To: gs-cygwin DOT com AT gluelogic DOT com, Bruno Haible , cygwin AT cygwin DOT com References: <1752276 DOT 7aRn1RRit1 AT nimes> <5022555 DOT upeRZZJTqa AT nimes> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Corinna Vinschen via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Corinna Vinschen , Bruno Haible , cygwin AT cygwin DOT com Content-Type: text/plain; charset="utf-8" Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 33K8aPRH003936 On Apr 20 03:14, gs-cygwin.com--- via Cygwin wrote: > On Mon, Apr 17, 2023 at 08:44:51PM +0200, Bruno Haible via Cygwin wrote: > > Btw, there are two more functions in the posix_spawn family meanwhile: > > * posix_spawn_file_actions_addchdir_np > > implemented by glibc [1], musl libc, macOS, FreeBSD [2], Solaris ≥ 11.3 > > used by a few packages (Firefox, Chromium, Rust) > > * posix_spawn_file_actions_addfchdir_np > > implemented in glibc, musl libc > > but not used by any package so far [3]. > > > > The next POSIX will contain these functions (without the _np suffix).[4] > > > > Bruno > > > > [1] https://sourceware.org/bugzilla/show_bug.cgi?id=17405 > > [2] https://man.freebsd.org/cgi/man.cgi?query=posix_spawn_file_actions_adddup2&apropos=0&sektion=3&manpath=FreeBSD+11-current&format=html > > [3] https://codesearch.debian.net/ > > [4] https://www.austingroupbugs.net/view.php?id=1208 > > With regards to [3] above, the next lighttpd release (lighttpd 1.4.70) > will use posix_spawn_file_actions_addfchdir_np(), where available, for > spawning CGI programs. > > I have not yet tested under cygwin, but under Linux the overhead of > initial CGI process creation can be greatly reduced by using > posix_spawn() instead of fork(),execve(). The speedup is inversely > proportional to how much work the target script performs (compared to > the overhead of initial process creation). Unfortunately you can't expect any noticable difference on Cygwin by using posix_spawn. While Cygwin has a spawn() family of functions, we don't (and can't... yet) use them. The problem is that we don't have a safe way to perform the spawn attributes and file actions which are supposed to be performed between the fork() and the exec() step when using the spawn() functions. This would have to be implemented first. So the difference between Linux and Cygwin is that Linux has a vfork() call, which performs a quick and shallow kind of fork() with the sole intention to exec() asap, and this is (via __clone or __clone3) used in glibc to implement posix_spawn(). We tried to implement a shallow vfork() on Cygwin as well, years ago, but it never really worked correctly, so we gave it up. vfork() on Cygwin is the same as a real fork(). Bottom line is, I will keep this problem in mind, and maybe we can come up with a new, quicker solution, using the spawn() functions. Our major problem is that we are just too few people actually hacking on Cygwin, and all of us are doing it mostly in spare time. Patches are, as always, gratefully received. Corinna -- 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