From owner-svn-src-head@FreeBSD.ORG Tue May 8 19:43:33 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35CC5106566C; Tue, 8 May 2012 19:43:33 +0000 (UTC) (envelope-from jlh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 20DB78FC0C; Tue, 8 May 2012 19:43:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q48JhW7Z049388; Tue, 8 May 2012 19:43:32 GMT (envelope-from jlh@svn.freebsd.org) Received: (from jlh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q48JhWEM049386; Tue, 8 May 2012 19:43:32 GMT (envelope-from jlh@svn.freebsd.org) Message-Id: <201205081943.q48JhWEM049386@svn.freebsd.org> From: Jeremie Le Hen Date: Tue, 8 May 2012 19:43:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235142 - head/usr.bin/stdbuf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2012 19:43:33 -0000 Author: jlh Date: Tue May 8 19:43:32 2012 New Revision: 235142 URL: http://svn.freebsd.org/changeset/base/235142 Log: Always define LD_32_PRELOAD so it works for 32 bits binaries on 64 bits platforms. Let rtld(1) decide if it needs to honor it or not. While here, fix a small bug in error reporting when asprintf(3) returns an error. Submitted by: kib Reviewed by: kib (mentor) MFC after: 1 week Modified: head/usr.bin/stdbuf/stdbuf.c Modified: head/usr.bin/stdbuf/stdbuf.c ============================================================================== --- head/usr.bin/stdbuf/stdbuf.c Tue May 8 19:33:31 2012 (r235141) +++ head/usr.bin/stdbuf/stdbuf.c Tue May 8 19:43:32 2012 (r235142) @@ -32,6 +32,7 @@ #include #define LIBSTDBUF "/usr/lib/libstdbuf.so" +#define LIBSTDBUF32 "/usr/lib32/libstdbuf.so" extern char *__progname; @@ -92,7 +93,17 @@ main(int argc, char *argv[]) LIBSTDBUF); if (i < 0 || putenv(preload1) == -1) - warn("Failed to set environment variable: %s", preload1); + warn("Failed to set environment variable: LD_PRELOAD"); + + preload0 = getenv("LD_32_PRELOAD"); + if (preload0 == NULL) + i = asprintf(&preload1, "LD_32_PRELOAD=" LIBSTDBUF32); + else + i = asprintf(&preload1, "LD_32_PRELOAD=%s:%s", preload0, + LIBSTDBUF32); + + if (i < 0 || putenv(preload1) == -1) + warn("Failed to set environment variable: LD_32_PRELOAD"); execvp(argv[0], argv); err(2, "%s", argv[0]);