linux: Fix posix_spawn return code if clone fails (BZ#29109)

Message ID 20220502154233.4007963-1-adhemerval.zanella@linaro.org
State Committed
Commit 71e2a681f18f617ab962bf8a139bd86d4d440e22
Headers
Series linux: Fix posix_spawn return code if clone fails (BZ#29109) |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Adhemerval Zanella Netto May 2, 2022, 3:42 p.m. UTC
  The __clone_internal returns the error on errno.

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

Comments

Adhemerval Zanella Netto May 6, 2022, 1:43 p.m. UTC | #1
I will commit this shortly if no one opposes it.

On 02/05/2022 12:42, Adhemerval Zanella wrote:
> The __clone_internal returns the error on errno.
> 
> Checked on x86_64-linux-gnu.
> ---
>  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 d703485e3f..d6f5ca89cd 100644
> --- a/sysdeps/unix/sysv/linux/spawni.c
> +++ b/sysdeps/unix/sysv/linux/spawni.c
> @@ -409,7 +409,7 @@ __spawnix (pid_t * pid, const char *file,
>  	__waitpid (new_pid, NULL, 0);
>      }
>    else
> -    ec = -new_pid;
> +    ec = errno;
>  
>    __munmap (stack, stack_size);
>
  

Patch

diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index d703485e3f..d6f5ca89cd 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -409,7 +409,7 @@  __spawnix (pid_t * pid, const char *file,
 	__waitpid (new_pid, NULL, 0);
     }
   else
-    ec = -new_pid;
+    ec = errno;
 
   __munmap (stack, stack_size);