[v4,1/6] linux: Do not reset signal handler in posix_spawn if it is already SIG_DFL

Message ID 20230112135853.3786675-2-adhemerval.zanella@linaro.org
State Committed
Commit ff9ffc805f5859f9f1fe3a006967b4cf7b191bb2
Headers
Series Optimize posix_spawn signal setup with clone3 |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Adhemerval Zanella Netto Jan. 12, 2023, 1:58 p.m. UTC
  There is no need to issue another sigaction if the disposition is
already SIG_DFL.

Checked on x86_64-linux-gnu.
---
 sysdeps/unix/sysv/linux/spawni.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Carlos O'Donell Jan. 18, 2023, 10:24 p.m. UTC | #1
On 1/12/23 08:58, Adhemerval Zanella wrote:
> There is no need to issue another sigaction if the disposition is
> already SIG_DFL.
> 
> Checked on x86_64-linux-gnu.

OK for 2.28.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/unix/sysv/linux/spawni.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
> index b7a6fe320d..a1a14a58ae 100644
> --- a/sysdeps/unix/sysv/linux/spawni.c
> +++ b/sysdeps/unix/sysv/linux/spawni.c
> @@ -129,7 +129,7 @@ __spawni_child (void *arguments)
>  	  else
>  	    {
>  	      __libc_sigaction (sig, 0, &sa);
> -	      if (sa.sa_handler == SIG_IGN)
> +	      if (sa.sa_handler == SIG_IGN || sa.sa_handler == SIG_DFL)
>  		continue;
>  	      sa.sa_handler = SIG_DFL;
>  	    }
  

Patch

diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index b7a6fe320d..a1a14a58ae 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -129,7 +129,7 @@  __spawni_child (void *arguments)
 	  else
 	    {
 	      __libc_sigaction (sig, 0, &sa);
-	      if (sa.sa_handler == SIG_IGN)
+	      if (sa.sa_handler == SIG_IGN || sa.sa_handler == SIG_DFL)
 		continue;
 	      sa.sa_handler = SIG_DFL;
 	    }