summaryrefslogtreecommitdiff
path: root/src/stdbuf.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2014-05-26 09:19:16 +0100
committerPádraig Brady <P@draigBrady.com>2014-05-26 16:38:18 +0100
commite4314774fd44bf2230a64f26c7f07383ddf6aa4c (patch)
treed1f1243874795e65654ce3ee4868a0369cfdb7d5 /src/stdbuf.c
parentb50186ef7d6a41d950879ef9b0183f69c8f60ae3 (diff)
downloadcoreutils-e4314774fd44bf2230a64f26c7f07383ddf6aa4c.tar.xz
stdbuf: support OS X
* src/stdbuf.c (set_LD_PRELOAD): Adjust to use Mac OS X specific environment variables on __APPLE__ platforms. Fixes http://bugs.gnu.org/17590
Diffstat (limited to 'src/stdbuf.c')
-rw-r--r--src/stdbuf.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/stdbuf.c b/src/stdbuf.c
index c648fc5d0..92ee28267 100644
--- a/src/stdbuf.c
+++ b/src/stdbuf.c
@@ -187,7 +187,12 @@ static void
set_LD_PRELOAD (void)
{
int ret;
- char *old_libs = getenv ("LD_PRELOAD");
+#ifdef __APPLE__
+ char const *preload_env = "DYLD_INSERT_LIBRARIES";
+#else
+ char const *preload_env = "LD_PRELOAD";
+#endif
+ char *old_libs = getenv (preload_env);
char *LD_PRELOAD;
/* Note this would auto add the appropriate search path for "libstdbuf.so":
@@ -239,9 +244,9 @@ set_LD_PRELOAD (void)
/* FIXME: Do we need to support libstdbuf.dll, c:, '\' separators etc? */
if (old_libs)
- ret = asprintf (&LD_PRELOAD, "LD_PRELOAD=%s:%s", old_libs, libstdbuf);
+ ret = asprintf (&LD_PRELOAD, "%s=%s:%s", preload_env, old_libs, libstdbuf);
else
- ret = asprintf (&LD_PRELOAD, "LD_PRELOAD=%s", libstdbuf);
+ ret = asprintf (&LD_PRELOAD, "%s=%s", preload_env, libstdbuf);
if (ret < 0)
xalloc_die ();
@@ -249,6 +254,10 @@ set_LD_PRELOAD (void)
free (libstdbuf);
ret = putenv (LD_PRELOAD);
+#ifdef __APPLE__
+ if (ret == 0)
+ ret = putenv ("DYLD_FORCE_FLAT_NAMESPACE=y");
+#endif
if (ret != 0)
{