From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 381733858D37; Wed, 19 Apr 2023 15:05:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 381733858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1681916723; bh=BjmeWra+HamCv3C/sEg91RsrMeKCPap1SuZ3UrlSiB4=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=HgOwRvIbEWBBt9dZR1t/J6MvJZ2qryJ7tGaWMxjNNNpCtZvNULKSLsoZmTm0QOeR/ yn90OATSH8oLCzbNIe3m0GP00rjJWecaj3JoxIHZKlP8qKY0PM3NC++0K+LpAr9WXD PkSb5SWAO41cuHYQ2jmSkUQY99ZwenZb0NKeyOhw= Received: by calimero.vinschen.de (Postfix, from userid 500) id EF242A80B9C; Wed, 19 Apr 2023 17:05:20 +0200 (CEST) Date: Wed, 19 Apr 2023 17:05:20 +0200 From: Corinna Vinschen To: Bruno Haible Cc: cygwin@cygwin.com Subject: Re: posix_spawn_file_actions_add[f]chdir_np Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: Bruno Haible , cygwin@cygwin.com References: <1752276.7aRn1RRit1@nimes> <5022555.upeRZZJTqa@nimes> <1962645.3CdzvNlvnA@nimes> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1962645.3CdzvNlvnA@nimes> List-Id: Hi Bruno, On Apr 19 13:24, Bruno Haible via Cygwin wrote: > Hi Corinna, > > > Actually I had some spare time yesterday so I came up with an > > implementation of posix_spawn_file_actions_addchdir_np and > > posix_spawn_file_actions_addfchdir_np. It's pretty straightforward: > > > > https://cygwin.com/cgit/newlib-cygwin/commit/?id=7e03fc35f528 > > Yes, it's pretty straightforward on Unix-like platforms. > > Note that there is a small inconsistency between implementations: > The manual page > https://man.freebsd.org/cgi/man.cgi?query=posix_spawn_file_actions_addfchdir_np&apropos=0&sektion=3&manpath=FreeBSD+13.2-RELEASE+and+Ports&arch=default&format=html > mentions that when the dirfd argument is negative, the > posix_spawn_file_actions_addfchdir function should fail with error EBADF. > musl libc, FreeBSD, macOS do this; glibc doesn't. Test program attached below. > Confirmed by looking at the source code: > - musl libc: > if (fd < 0) return EBADF; > - FreeBSD: > if (fildes < 0) > return (EBADF); Ok, good to know. I implemented it like glibc, so fd isn't tested in posix_spawn_file_actions_addfchdir_np, but Austin group issue 1208 at https://www.austingroupbugs.net/view.php?id=1208 documents it like it's implemented in musl and FreeBSD: ERRORS The posix_spawn_file_actions_addfchdir( ) function shall fail if: [EBADF] The value specified by fildes is negative. [...] I will fix this in Cygwin. > > You can install the just building test release > > cygwin-3.5.0-0.287.g53f7fb20a064 via our installer, if you'd > > like to test it. > > > > Actually... do you have a testcase readily available to share with us? > > Indeed, I'm not likely to install test releases. (Due to the way I work > with my Windows VM, it's a bit clumsy to create a snapshot.) I don't quite understand the snapshot thingy. Can't you just run setup in your Windows VM? > It's easier > for me to provide you a test case, with the unit tests from Gnulib. > [...] > You can download the resulting tarball from > https://haible.de/bruno/gnu/testdir-posix-spawn.tar.gz . > > When configuring it, set the environment variable > gl_cv_func_posix_spawnp_secure_exec=yes . This will prevent the > autoconfiguration from attempting to override the entire posix_spawn facility: > $ env gl_cv_func_posix_spawnp_secure_exec=yes ./configure > Verify through > $ grep REPLACE_POSIX_SPAWN config.status > that the values of REPLACE_POSIX_SPAWN and REPLACE_POSIX_SPAWNP are 0; > if they are 1, the output of 'configure' should reveal why. > > Then build it: > $ make > Verify through > $ ls -l gllib/*.o > that no posix_spawn_*.o object file was built. > > Then run > $ make check > and it will run the unit tests against the Cygwin libc. It's likely > that you will see 1 test failure (test-posix_spawnp-script); but > other than that, there ought to be no test failures. Indeed, thanks a lot! I checked all the above and ran the testsuite. All tests pass except the test-posix_spawnp-script.exe testcase. Great! Thanks again, Corinna