From 2053c11331991818882f7cf023ed2ce4ff44b274 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Netto Date: Thu, 12 Jan 2023 10:58:51 -0300 Subject: 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 --- include/clone_internal.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/clone_internal.h b/include/clone_internal.h index f8198d8059..3b6cd85f02 100644 --- a/include/clone_internal.h +++ b/include/clone_internal.h @@ -24,6 +24,11 @@ extern int __clone3 (struct clone_args *__cl_args, size_t __size, fall back to clone or clone2. */ extern int __clone_internal (struct clone_args *__cl_args, int (*__func) (void *__arg), void *__arg); +/* The fallback code which calls clone/clone2 based on clone3 arguments. */ +extern int __clone_internal_fallback (struct clone_args *__cl_args, + int (*__func) (void *__arg), + void *__arg) + attribute_hidden; #ifndef _ISOMAC libc_hidden_proto (__clone3) -- cgit v1.2.3