From patchwork Wed Sep 23 10:51:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 40479 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F1BB13949D97; Wed, 23 Sep 2020 10:52:18 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from flashner.co.il (flashner.co.il [178.62.234.194]) by sourceware.org (Postfix) with ESMTP id CD0F33894C3E for ; Wed, 23 Sep 2020 10:52:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CD0F33894C3E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=flashner.co.il Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efraim@flashner.co.il Received: from localhost (unknown [31.210.181.177]) by flashner.co.il (Postfix) with ESMTPSA id 05DBC40049; Wed, 23 Sep 2020 10:52:14 +0000 (UTC) From: Efraim Flashner To: libc-alpha@sourceware.org Subject: [PATCH] posix: Don't automatically fail if _LIBC_REENTRANT isn't defined. Date: Wed, 23 Sep 2020 13:51:26 +0300 Message-Id: <20200923105126.13566-1-efraim@flashner.co.il> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_ABUSEAT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Efraim Flashner Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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;