posix_spawn: skip SIGKILL & SIGSTOP

Message ID TYCPR01MB10926CFBFEF32CA355593C1B4F8D62@TYCPR01MB10926.jpnprd01.prod.outlook.com
State New
Headers
Series posix_spawn: skip SIGKILL & SIGSTOP |

Commit Message

王宇逸 March 10, 2025, 2:55 p.m. UTC
  sigaction() returns EINVAL on SIGKILL & SIGSTOP. We need to skip them.
---
  newlib/libc/posix/posix_spawn.c | 2 ++
  1 file changed, 2 insertions(+)
  

Comments

Takashi Yano March 11, 2025, 8:46 a.m. UTC | #1
On Mon, 10 Mar 2025 22:55:17 +0800
Yuyi Wang wrote:
> 
> sigaction() returns EINVAL on SIGKILL & SIGSTOP. We need to skip them.
> ---
>   newlib/libc/posix/posix_spawn.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/newlib/libc/posix/posix_spawn.c b/newlib/libc/posix/posix_spawn.c
> index 6fd6159d0..46e4e5369 100644
> --- a/newlib/libc/posix/posix_spawn.c
> +++ b/newlib/libc/posix/posix_spawn.c
> @@ -199,6 +199,8 @@ process_spawnattr(const posix_spawnattr_t sa)
> 
>       if (sa->sa_flags & POSIX_SPAWN_SETSIGDEF) {
>           for (i = 1; i < NSIG; i++) {
> +            if (i == SIGKILL || i == SIGSTOP)
> +                continue;
>               if (sigismember(&sa->sa_sigdefault, i))
>                   if (sigaction(i, &sigact, NULL) != 0)
>                       return (errno);
> -- 
> 2.48.1.windows.1-2
> 

Thanks for the patch. LGTM.

Corinna, is this as you intended?
  
Corinna Vinschen March 11, 2025, 10:45 a.m. UTC | #2
On Mar 11 17:46, Takashi Yano wrote:
> On Mon, 10 Mar 2025 22:55:17 +0800
> Yuyi Wang wrote:
> > 
> > sigaction() returns EINVAL on SIGKILL & SIGSTOP. We need to skip them.
> > ---
> >   newlib/libc/posix/posix_spawn.c | 2 ++
> >   1 file changed, 2 insertions(+)
> > 
> > diff --git a/newlib/libc/posix/posix_spawn.c b/newlib/libc/posix/posix_spawn.c
> > index 6fd6159d0..46e4e5369 100644
> > --- a/newlib/libc/posix/posix_spawn.c
> > +++ b/newlib/libc/posix/posix_spawn.c
> > @@ -199,6 +199,8 @@ process_spawnattr(const posix_spawnattr_t sa)
> > 
> >       if (sa->sa_flags & POSIX_SPAWN_SETSIGDEF) {
> >           for (i = 1; i < NSIG; i++) {
> > +            if (i == SIGKILL || i == SIGSTOP)
> > +                continue;
> >               if (sigismember(&sa->sa_sigdefault, i))
> >                   if (sigaction(i, &sigact, NULL) != 0)
> >                       return (errno);
> > -- 
> > 2.48.1.windows.1-2
> > 
> 
> Thanks for the patch. LGTM.
> 
> Corinna, is this as you intended?

Sure, just go ahead.


Thanks,
Corinna
  
Takashi Yano March 11, 2025, 11:22 a.m. UTC | #3
On Tue, 11 Mar 2025 17:46:35 +0900
Takashi Yano wrote:
> On Mon, 10 Mar 2025 22:55:17 +0800
> Yuyi Wang wrote:
> > 
> > sigaction() returns EINVAL on SIGKILL & SIGSTOP. We need to skip them.
> > ---
> >   newlib/libc/posix/posix_spawn.c | 2 ++
> >   1 file changed, 2 insertions(+)
> > 
> > diff --git a/newlib/libc/posix/posix_spawn.c b/newlib/libc/posix/posix_spawn.c
> > index 6fd6159d0..46e4e5369 100644
> > --- a/newlib/libc/posix/posix_spawn.c
> > +++ b/newlib/libc/posix/posix_spawn.c
> > @@ -199,6 +199,8 @@ process_spawnattr(const posix_spawnattr_t sa)
> > 
> >       if (sa->sa_flags & POSIX_SPAWN_SETSIGDEF) {
> >           for (i = 1; i < NSIG; i++) {
> > +            if (i == SIGKILL || i == SIGSTOP)
> > +                continue;
> >               if (sigismember(&sa->sa_sigdefault, i))
> >                   if (sigaction(i, &sigact, NULL) != 0)
> >                       return (errno);
> > -- 
> > 2.48.1.windows.1-2
> > 
> 
> Thanks for the patch. LGTM.

Sorry, your patch does not apply cleanly, because the
tab is expanded to spaces. Please fix that.
  

Patch

diff --git a/newlib/libc/posix/posix_spawn.c b/newlib/libc/posix/posix_spawn.c
index 6fd6159d0..46e4e5369 100644
--- a/newlib/libc/posix/posix_spawn.c
+++ b/newlib/libc/posix/posix_spawn.c
@@ -199,6 +199,8 @@  process_spawnattr(const posix_spawnattr_t sa)

      if (sa->sa_flags & POSIX_SPAWN_SETSIGDEF) {
          for (i = 1; i < NSIG; i++) {
+            if (i == SIGKILL || i == SIGSTOP)
+                continue;
              if (sigismember(&sa->sa_sigdefault, i))
                  if (sigaction(i, &sigact, NULL) != 0)
                      return (errno);