tags:

views:

130

answers:

3

Hi all,

I have used pipes to facilitate interprocess communication. They work just fine. But in my scenario I want to close and reopen the read end of the file descriptor fd[0]. Does anyone know how to do that?

+2  A: 

You can't reopen a pipe between two processes after either side has closed it.

dmazzoni
+3  A: 

You cannot reopen an unnamed pipe. If you really need to do this reopening magic, consider using named pipes, that can be opened and reopened as many times as you wish. But before doing it, consider whether it makes any sense at all.

David Rodríguez - dribeas
A: 

Hi,rocknroll, sorry to post my problem here. I come across a problem : I need to terminate a thread before it finishes execution. And the thread is performing some heavy computation and I want to stop it wherever and whenever I need to . thanks a lot.

Create an unnamed pipe, write to the pipe in the main thread when you want to terminate the thread and read from this pipe in the run function of the thread you want to terminate. I hope this does the trick for you. Figure out the mechanisms for the unnamed pipe, its very easy to use. In my case it eliminated the need for mutexes.
rocknroll