I've successfully used a hook under Linux with this article: http://hackerboss.com/overriding-system-functions-for-fun-and-profit/

Now I want to make my .so file load every time espeak loads up, no matter if it's called from another application. How do I do that?


You could move the espeak binary to something like espeak-real, and replace it with a small script that sets LD_PRELOAD before exec'ing espeak-real.

#! /bin/bash
export LD_PRELOAD=/your/lib.so
exec espeak-real "$@"

(stdin/out/err redirections take care of themselves.)

  • Can you please give me example, cause I'm not good with exec. – blez May 7 '12 at 12:02
  • exec espeak-real. Couldn't be simpler. Unless you need to pass command line arguments? – Mat May 7 '12 at 12:02
  • I'll need to, yes. Even some streaming stdin. – blez May 7 '12 at 12:04
  • Edited with an example. – Mat May 7 '12 at 12:06
  • Thank you. Will it work as same as executable if I replace it? (I'm new to unix) – blez May 7 '12 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.