简体   繁体   中英

Using an ad-hoc libc with a tool which is an argument of another tool

I need to use a particular libc to run a tool (cp). The problem is that this tool has to be used as argument of another tool (for example timeout) and I don't want to use the modified libc with this one.

I tried to do:

timeout 10 LD_LIBRARY_PATH=/path/to/mod/libc/ cp a b

But I received the error:

timeout: failed to run command 'LD_LIBRARY_PATH=/path/to/mod/libc/': No such file or directory

And, as I said, I can't do:

LD_LIBRARY_PATH=/path/to/mod/libc/ timeout 10 cp a b

as timeout would use the modified libc. Is there any way to do this?

You can achieve that by using the env utility:

timeout 10 /usr/bin/env LD_LIBRARY_PATH=/path/to/mod/libc/ cp a b

Env will set the environment variable and exec the other utility with that environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM