简体   繁体   中英

Is it possible to redirect input/output from fd other then stdin,stdout,stderr

I'm aware of piping in linux shell (i have a very basic knowledge of it).

Lets say i have an executable that i know reads from a specific file (or from a socket), is it possible to redirect the output/input of this file using shell piping, like it is with stdin/out/err?

Thanks

Yes, absolutely. One way is to call dup() or dup2() and close() the original file. But of course, you'll need source code to modify the original program.

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