LD_PRELOAD affects new child even after unsetenv(“LD_PRELOAD”)
问题 my code is as follows: preload.c, with the following content: #include <stdio.h> #include <stdlib.h> int __attribute__((constructor)) main_init(void) { printf("Unsetting LD_PRELOAD: %x\n",unsetenv("LD_PRELOAD")); FILE *fp = popen("ls", "r"); pclose(fp); } then in the shell (do the 2nd command with care!!): gcc preload.c -shared -Wl,-soname,mylib -o mylib.so -fPIC LD_PRELOAD=./mylib.so bash !!! be carefull with the last command it will result with endless loop of forking "sh -c ls". Stop it