diff mbox series

posix: Don't automatically fail if _LIBC_REENTRANT isn't defined.

Message ID 20200923105126.13566-1-efraim@flashner.co.il
State New
Headers show
Series posix: Don't automatically fail if _LIBC_REENTRANT isn't defined. | expand

Commit Message

Efraim Flashner Sept. 23, 2020, 10:51 a.m. UTC
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(-)

-- 
2.28.0

Comments

Adhemerval Zanella via Libc-alpha Sept. 23, 2020, 11:56 a.m. UTC | #1
* 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
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
diff mbox series

Patch

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;