Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.