|
|
| We don't bite newbies here... much | |
| PerlMonks |
FileHandles and threadsby sodul (Initiate) |
| on Sep 21, 2005 at 08:25 UTC ( [id://493754]=perlquestion: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.sodul has asked for the wisdom of the Perl Monks concerning the following question: Hi Monks, I have a Perl script that need to be threaded (handles http requests) and also need to read and write in a forked subprocess. The subprocess has a very slow start time and I call it using the open2 function. My problem is that I cannot find a way to share the filehandles between my threads. I can do: use FileHandle; use threads::shared; use vars qw ($in, $out); share $in; share $out; # but if I try to put a handle in the variables "share" will complain # that the type is invalid $in =new FileHandle; # error So is it possible to open/create a filehandle in a thread and share/reuseit in a different thread ? Reopening with a new file handle is not an option because of the slow loading of the subprocess. Been stuck for days on trying to figure out a way to make it work. I'm looking forward to your replies, Regards. Stephane
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||