in reply to Re: Redirecting stdout with threads
in thread Redirecting stdout with threads

Thanks for your reply.
Maybe the example looks a bit weird because i deleted all code that isnt necessary to show my problem.
I want to use threads cause i feel the communication is easier than with processes. If i create process and a pipe for communication this would result in something like
while (..) { $tmp = <READ_FROM_OTHER_PROCESS> }
which blocks one of my processes.
I tried the ipc forks library instead of threads and it works fine.

Replies are listed 'Best First'.
Re^3: Redirecting stdout with threads
by kennethk (Abbot) on Mar 15, 2009 at 15:37 UTC
    Both methods of IPC work, but it's a very good idea to stick with one consistent approach throughout your code. If you would prefer doing the whole thing with threads, I would refer you to threads on Windows. I posted this question when I was learning threads in Perl, including message passing concepts. Since you are worried about blocking operations, you can maintain your fork/pipe approach and use signals to facilitate a timeout on the connection. There are also a number of IPC-modules on CPAN that may help.