Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 to do that?

share|improve this question
up vote 7 down vote accepted

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.)

share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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