mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
posix: Fix system error return value [BZ #25715]
It fixes 5fb7fc9635
when posix_spawn fails.
Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
@@ -101,7 +101,8 @@ cancel_handler (void *arg)
|
||||
static int
|
||||
do_system (const char *line)
|
||||
{
|
||||
int status;
|
||||
int status = -1;
|
||||
int ret;
|
||||
pid_t pid;
|
||||
struct sigaction sa;
|
||||
#ifndef _LIBC_REENTRANT
|
||||
@@ -144,14 +145,14 @@ do_system (const char *line)
|
||||
__posix_spawnattr_setflags (&spawn_attr,
|
||||
POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK);
|
||||
|
||||
status = __posix_spawn (&pid, SHELL_PATH, 0, &spawn_attr,
|
||||
(char *const[]){ (char*) SHELL_NAME,
|
||||
(char*) "-c",
|
||||
(char *) line, NULL },
|
||||
__environ);
|
||||
ret = __posix_spawn (&pid, SHELL_PATH, 0, &spawn_attr,
|
||||
(char *const[]){ (char *) SHELL_NAME,
|
||||
(char *) "-c",
|
||||
(char *) line, NULL },
|
||||
__environ);
|
||||
__posix_spawnattr_destroy (&spawn_attr);
|
||||
|
||||
if (status == 0)
|
||||
if (ret == 0)
|
||||
{
|
||||
/* Cancellation results in cleanup handlers running as exceptions in
|
||||
the block where they were installed, so it is safe to reference
|
||||
@@ -186,6 +187,9 @@ do_system (const char *line)
|
||||
}
|
||||
DO_UNLOCK ();
|
||||
|
||||
if (ret != 0)
|
||||
__set_errno (ret);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user