1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
// $Id$ 
// 
// Detection and workaround for Redhat 9's New Posix Thread Library. 
// 
// 2003-09-23 Henrik Grubbström 
 
void run(object env) 
{ 
#if !constant(Mysql.mysql) 
  // The Mysql module when compiled on RedHat 7.3 contains the symbol 
  // "errno@@GLIBC_2.0", which is not available in modern GLIBCs. 
  write("   Broken Mysql -- Checking for NPTL... "); 
  if (search(Process.popen("/usr/bin/getconf GNU_LIBPTHREAD_VERSION 2>/dev/null"), 
             "NPTL") >= 0) { 
    write("yes (%s)\n"); 
    write("   Checking if LD_ASSUME_KERNEL might work... "); 
    // On recent releases of Linux, binaries often fail with 
    //   error while loading shared libraries: libc.so.6: cannot 
    //   open shared object file: No such file or directory 
    // when LD_ASSUME_KERNEL is set. We test with a binary that 
    // the start-script will attempt to use: sed. 
    object in = Stdio.File(); 
    object out = Stdio.File(); 
    object err = Stdio.File(); 
    Process.Process p = 
      Process.Process(({ "sed", "-ed" }), ([ 
                        "stdin": in->pipe(Stdio.PROP_REVERSE), 
                        "stdout": out->pipe(), 
                        "stderr": err->pipe(), 
                        "env":getenv() + ([ 
                          "LD_ASSUME_KERNEL":"2.4.1", 
                        ]) 
                      ])); 
    in->close(); 
    out->close(); 
    err->read(); 
    err->close(); 
    if (!p->wait()) { 
      write("yes\n"); 
      env->set("LD_ASSUME_KERNEL", "2.4.1"); 
      return; 
    } 
  } 
  write("no\n"); 
#endif 
}