Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Jul 2012 13:53:03 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: system() using vfork() or posix_spawn()
Message-ID:  <20120730105303.GU2676@deviant.kiev.zoral.com.ua>
In-Reply-To: <20120730102408.GA19983@stack.nl>
References:  <20120730102408.GA19983@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help

--kAxYX6Dg+VZz1yCk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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 system
> 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.
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.

--kAxYX6Dg+VZz1yCk
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (FreeBSD)

iEYEARECAAYFAlAWZ48ACgkQC3+MBN1Mb4jwrgCeM71zpb+alvqQpd3XPXBmj5My
9VwAn3LCDmMqkKLu41tAT01/aWRxQCRX
=WDAV
-----END PGP SIGNATURE-----

--kAxYX6Dg+VZz1yCk--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120730105303.GU2676>