I have a binary program developed for Linux which reads lines from a server’s network stream. Its communication is encrypted in a way that would take me too long to figure out, so I can’t rewrite it.
After outputting each line, the program calls nanosleep(100000000) (I found this using strace) However, when the server sends multiple lines in quick succession, there’s a big delay between the actual stream and the output.
Since I don’t have the source code of the program, my question: is there a way to reduce the sleep time of this software? “Accelerating” it?
For reference, the program is Punkbuster’s PBUcon
You can try the LD_PRELOAD trick:
Then compile with:
And then run your program with:
There are a few things you should be aware of:
nanosleep, not only the ones you don’t like, and that can have subtle undesired effects. You could check for the particular values of the argument, if you feel you need it.UPDATE: If you want to chain the call to the original function, you can do the following:
If you wanted to avoid GNU extensions (
RTLD_NEXTis one) you would have to discover the name of the shared library that contains the function, with for example:And then, in the function do: