Is there a way to figure out which program is the one being targeted by a LD_PRELOAD?
LD_PRELOAD=/path/to/libstuff.so ./stuff <args>
Like when building the libstuff
library in C/C++ and when it's preloaded is there a way to figure out that the program targeted is stuff
?
And is this a safe way of doing so by if it were the case that the file is stuff
then do things and else just let the lib die.
IF this is not recommended
The reason for asking is I can't get
HOME=$WORK_PATH start-stop-daemon --start --chuid servers --quiet --background --nicelevel -1 --pidfile $PIDFILE --make-pidfile --exec $WORK_PATH/program <args>
to work with LD_PRELOAD
targeting program
and not start-stop-daemon
I don't know if this is allowed going offtopic like this (sorry incase) but if someone could help me with that would make my day too.
Thanks in advance.
Run it using the env
program, which modifies the environment then calls exec
:
start-stop-daemon --start --chuid servers --quiet --background --nicelevel -1 --pidfile $PIDFILE --make-pidfile \
--exec env "LD_PRELOAD=/path/to/libstuff.so" "HOME=$WORK_PATH" "$WORK_PATH/program" <args>