Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 May 2012 19:43:32 +0000 (UTC)
From:      Jeremie Le Hen <jlh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r235142 - head/usr.bin/stdbuf
Message-ID:  <201205081943.q48JhWEM049386@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <unistd.h>
 
 #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]);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205081943.q48JhWEM049386>