public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Efraim Flashner <efraim@flashner.co.il>
To: libc-alpha@sourceware.org
Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	Efraim Flashner <efraim@flashner.co.il>
Subject: [PATCH] posix: Don't automatically fail if _LIBC_REENTRANT isn't defined.
Date: Wed, 23 Sep 2020 13:51:26 +0300	[thread overview]
Message-ID: <20200923105126.13566-1-efraim@flashner.co.il> (raw)

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(-)

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;
-- 
2.28.0


             reply	other threads:[~2020-09-23 10:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23 10:51 Efraim Flashner [this message]
2020-09-23 11:56 ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200923105126.13566-1-efraim@flashner.co.il \
    --to=efraim@flashner.co.il \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).