简体   繁体   中英

redirect output from file to three running thread

I want to use 'cat myclip.avi' command to send the output to three running thread, i am trying to process same clip file to produce three different result. can i use dup2 or how i can make pipe with thread not fork?

Sorry about the question being so vague. Maybe I need to reinforce my understanding of dup2. actually i am using external application let say "linux cat" to read data that in thread one, then data have to pass to two other thread to process it, also those are using external application let say "sort ascending" and "sort descending" assume sort application accept only pip in only, what do then?

"How can I make pipe with thread not fork?" You can't make a pipe with either fork or thread; you make a pipe with pipe. Suppose you have 3 total threads, each with access to the same data. One thread reads data into a buffer and uses the data. It then blocks (on a mutex of some sort) until the other two threads each use the data. Repeat. Since you are using threads, you don't need a pipe at all.

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