From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 6 08:25:41 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6AC5A106566B for ; Mon, 6 Aug 2012 08:25:41 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id C23F98FC1A for ; Mon, 6 Aug 2012 08:25:40 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q768PmQH010701; Mon, 6 Aug 2012 11:25:48 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q768PZo6026385; Mon, 6 Aug 2012 11:25:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q768PZNs026384; Mon, 6 Aug 2012 11:25:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 6 Aug 2012 11:25:35 +0300 From: Konstantin Belousov To: Jilles Tjoelker Message-ID: <20120806082535.GI2676@deviant.kiev.zoral.com.ua> References: <20120730102408.GA19983@stack.nl> <20120730105303.GU2676@deviant.kiev.zoral.com.ua> <20120805215432.GA28704@stack.nl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="AhJ190OLnagu9UvS" Content-Disposition: inline In-Reply-To: <20120805215432.GA28704@stack.nl> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org Subject: Re: system() using vfork() or posix_spawn() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Aug 2012 08:25:41 -0000 --AhJ190OLnagu9UvS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Aug 05, 2012 at 11:54:32PM +0200, Jilles Tjoelker wrote: > On Mon, Jul 30, 2012 at 01:53:03PM +0300, Konstantin Belousov wrote: > > On Mon, Jul 30, 2012 at 12:24:08PM +0200, Jilles Tjoelker wrote: > > > People sometimes use system() from large address spaces where it would > > > improve performance greatly to use vfork() instead of fork(). >=20 > > > A simple approach is to change fork() to vfork(), although I have not > > > tried this. It seems safe enough to use sigaction and sigprocmask sys= tem > > > calls in the vforked process. >=20 > > > Alternatively, we can have posix_spawn() do the vfork() with signal > > > changes. This avoids possible whining from compilers and static > > > analyzers about using vfork() in system.c. However, I do not like the > > > tricky code for signals and that it adds lines of code. >=20 > > > This is lightly tested. >=20 > > It is interesting to note that for some time our vfork(2) no longer > > stops the whole forked process (parent), only the forking thread is > > waiting for the child exit or exec. I am not sure is this point > > important for system(3), but determined code can notice the difference > > from the fork->vfork switch. >=20 > Neither fork nor vfork call thread_single(SINGLE_BOUNDARY), so this is > not a difference. It is the difference, because vforked child shares parent address space. >=20 > Thread singling may be noticeable from a failing execve() (but only in > the process doing execve()) and in the rare case of rfork() without > RFPROC. No, other running threads in parent affect vforked child till exec or exit. In fact, I would classify this as bug, but not a serious one. --AhJ190OLnagu9UvS Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlAff38ACgkQC3+MBN1Mb4jB+ACg4tGn73m900YArlOgJJnXXN23 VpEAoMfnQYjoWd4MBo9dz6PCtzqdHyE2 =UYgY -----END PGP SIGNATURE----- --AhJ190OLnagu9UvS--