Comment Comment by shaded-enmity Turns out (1) works: #include <stdio.h> #include <stdlib.h> static void begin() __attribute__((constructor)); void begin() { unsetenv("LD_PRELOAD"); } Build with: gcc -shared -fpie -o library.so library.c Test: LD_PRELOAD=~/library.so env | grep LD_PRELOAD parent shaded-enmity 4 years ago