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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: FileHandles and threads
by BrowserUk (Patriarch) on Sep 21, 2005 at 14:08 UTC | |
by sodul (Initiate) on Sep 22, 2005 at 00:10 UTC | |
by zentara (Archbishop) on Sep 22, 2005 at 18:21 UTC | |
by BrowserUk (Patriarch) on Sep 22, 2005 at 20:17 UTC | |
Re: FileHandles and threads
by Anonymous Monk on Apr 20, 2013 at 18:12 UTC |
Back to
Seekers of Perl Wisdom