libredirect: workaround dyld env not inherited
This commit is contained in:
parent
d1a3b5c4cc
commit
7acc0e054c
1 changed files with 14 additions and 1 deletions
|
@ -308,7 +308,20 @@ static char * replace_string(char * buf, char * from, char * to) {
|
|||
}
|
||||
|
||||
static void rewriteSystemCall(const char * command, char * buf) {
|
||||
strcpy(buf, command);
|
||||
char * p = buf;
|
||||
|
||||
#ifdef __APPLE__
|
||||
// The dyld environment variable is not inherited by the subprocess spawned
|
||||
// by system(), so this hack redefines it.
|
||||
Dl_info info;
|
||||
dladdr(&rewriteSystemCall, &info);
|
||||
p = stpcpy(p, "export DYLD_INSERT_LIBRARIES=");
|
||||
p = stpcpy(p, info.dli_fname);
|
||||
p = stpcpy(p, ";");
|
||||
#endif
|
||||
|
||||
stpcpy(p, command);
|
||||
|
||||
for (int n = 0; n < nrRedirects; ++n) {
|
||||
replace_string(buf, from[n], to[n]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue