components/coreutils/patches/stdbuf.c.patch
changeset 1895 1f133713df64
parent 1465 26be70b523fc
child 2050 7c6a1559c620
equal deleted inserted replaced
1894:ac68129fb8d6 1895:1f133713df64
     1 Changes needed to get stdbuf to successfully preload libstdbuf.so
     1 Change needed to get stdbuf to successfully preload libstdbuf.so
     2 for both 32-bit and 64-bit applications. See comment in the patch
     2 for both 32-bit and 64-bit applications.
     3 for more details.
       
     4 
     3 
     5 --- coreutils-8.16/src/stdbuf.c.orig	2013-09-04 19:05:35.225857588 -0700
     4 This change has been passed upstream.
     6 +++ coreutils-8.16/src/stdbuf.c	2013-09-04 19:11:51.945113130 -0700
     5 
     7 @@ -195,37 +195,13 @@
     6 --- coreutils-8.16/src/stdbuf.c.orig	2014-05-12 13:48:24.644347899 -0700
     8       gcc stdbuf.c -Wl,-rpath,'$ORIGIN' -Wl,-rpath,$PKGLIBEXECDIR
     7 +++ coreutils-8.16/src/stdbuf.c	2014-05-14 09:45:52.507614923 -0700
     9       However we want the lookup done for the exec'd command not stdbuf.
     8 @@ -200,6 +200,14 @@
       
     9    char const *const search_path[] = {
       
    10      program_path,
       
    11      PKGLIBEXECDIR,
       
    12 +
       
    13 +   /* Since we don't link against libstdbuf.so, we need to LD_PRELOAD it.
       
    14 +      libstdbuf.so lives in /usr/lib and /usr/lib/64, so we just use a
       
    15 +      search path value of "" and that equates to LD_PRELOAD=libstdbuf.so,
       
    16 +      and ld.so.1 finds the right one associated with the process class.
       
    17 +      ie. we don't use full path names for the preload names.  */
       
    18 +
       
    19 +    "",              /* System default */
       
    20      NULL
       
    21    };
    10  
    22  
    11 -     Since we don't link against libstdbuf.so add it to PKGLIBEXECDIR
       
    12 -     rather than to LIBDIR.  */
       
    13 -  char const *const search_path[] = {
       
    14 -    program_path,
       
    15 -    PKGLIBEXECDIR,
       
    16 -    NULL
       
    17 -  };
       
    18 +     Since we don't link against libstdbuf.so, we need to LD_PRELOAD it.
       
    19 +     As libstdbuf.so lives in /usr/lib and /usr/lib/64, we just use
       
    20 +     LD_PRELOAD=libstdbuf.so, and ld.so.1 finds the right one associated
       
    21 +     with the process class. ie. we don't use full path names for the
       
    22 +     preload names.  */
       
    23  
       
    24 -  char const *const *path = search_path;
       
    25 -  char *libstdbuf;
       
    26 -
       
    27 -  while (true)
       
    28 -    {
       
    29 -      struct stat sb;
       
    30 -
       
    31 -      if (!**path)              /* system default  */
       
    32 -        {
       
    33 -          libstdbuf = xstrdup (LIB_NAME);
       
    34 -          break;
       
    35 -        }
       
    36 -      ret = asprintf (&libstdbuf, "%s/%s", *path, LIB_NAME);
       
    37 -      if (ret < 0)
       
    38 -        xalloc_die ();
       
    39 -      if (stat (libstdbuf, &sb) == 0)   /* file_exists  */
       
    40 -        break;
       
    41 -      free (libstdbuf);
       
    42 -
       
    43 -      ++path;
       
    44 -      if ( ! *path)
       
    45 -        error (EXIT_CANCELED, 0, _("failed to find %s"), quote (LIB_NAME));
       
    46 -    }
       
    47 +  char *libstdbuf = xstrdup (LIB_NAME);
       
    48  
       
    49    /* FIXME: Do we need to support libstdbuf.dll, c:, '\' separators etc?  */
       
    50