views:

42

answers:

1

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?

A: 

"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.

William Pursell