linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn
commit2053c11331991818882f7cf023ed2ce4ff44b274
authorAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Thu, 12 Jan 2023 13:58:51 +0000 (12 10:58 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 1 Feb 2023 11:42:11 +0000 (1 08:42 -0300)
treeb1edaafb8036456c39bff1756ed8827922c0b3b5
parent2290cf73cce1292d9345a8183fd29ae3994a9481
linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn

The clone3 flag resets all signal handlers of the child not set to
SIG_IGN to SIG_DFL.  It allows to skip most of the sigaction calls
to setup child signal handling, where previously a posix_spawn
had to issue 2 times NSIG sigaction calls (one to obtain the current
disposition and another to set either SIG_DFL or SIG_IGN).

With POSIX_SPAWN_SETSIGDEF the child will setup the signal for the case
where the disposition is SIG_IGN.

The code must handle the fallback where clone3 is not available. This is
done by splitting __clone_internal_fallback from __clone_internal.

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
include/clone_internal.h
posix/Makefile
posix/tst-spawn7.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/Makefile
sysdeps/unix/sysv/linux/clone-internal.c
sysdeps/unix/sysv/linux/clone3.h
sysdeps/unix/sysv/linux/spawni.c