posix: Don't automatically fail if _LIBC_REENTRANT isn't defined.
Commit Message
If status is instantiated as -1 then do_system() will always fail in
some circumstances.
---
I was working on porting GNU Guix to powerpc-linux and I stumbled across
what I'm assuming is a bug. As part of building the bootstrap binaries
to build the entire system a static copy of guile is created, using a
static copy of glibc. When this copy of guile was used inside a Guix
build container the 'system' command from guile would unconditionally
error. 'system' uses the default 'sh'
(https://www.gnu.org/software/guile/manual/html_node/Processes.html#index-system)
which, for the static glibc, we've patched to be 'sh' and not '/bin/sh'
so guile can find it in the environment, which intentionally lacks /bin/sh.
This has worked for all the other architectures we support.
When I was looking through code to see what might've changed I realized
that most instances of status were changed to ret, and status was now
initialized to -1. By either reverting [BZ #25715]
f09542c584b121da0322fde4b55306d512b85d93 or by initializing status to 0
I was able to continue with the porting effort.
---
sysdeps/posix/system.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
* Efraim Flashner:
> diff --git a/sysdeps/posix/system.c b/sysdeps/posix/system.c
> index a03f478fc7..19d07d2581 100644
> --- a/sysdeps/posix/system.c
> +++ b/sysdeps/posix/system.c
> @@ -101,7 +101,7 @@ cancel_handler (void *arg)
> static int
> do_system (const char *line)
> {
> - int status = -1;
> + int status = 0;
> int ret;
> pid_t pid;
> struct sigaction sa;
I don't think this is correct. You are just hiding an error return from
posix_spawn, I think.
A test case (against unpatched glibc) would help to clarify what you are
looking for.
Thanks,
Florian
@@ -101,7 +101,7 @@ cancel_handler (void *arg)
static int
do_system (const char *line)
{
- int status = -1;
+ int status = 0;
int ret;
pid_t pid;
struct sigaction sa;