[sane-devel] Q: threads and pipes

Henning Meier-Geinitz henning@meier-geinitz.de
Mon, 12 Jan 2004 20:00:02 +0100


Hi,


On Mon, Jan 12, 2004 at 07:42:42PM +0100, Oliver Rauch wrote:
> Does anyone know how pipes have to be handled with threads?!
> 
> when fork() is used then I close the read end in the reader_process and the
> write end in the main process. Should I also do this when working with
> threads or should I keep both ends opened ind both treads?

I'm using code like this in mustek.c:

  if (sanei_thread_is_forked ())
    {
      DBG (4, "reader_process: using fork ()\n");
      close (s->pipe);
      s->pipe = -1;
    }
  else
    {
      DBG (4, "reader_process: using threads\n");
    }

So I think you can't close the pipe in threads.

Bye,
  Henning