Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: threads, file handles and wxPerl

by zentara (Archbishop)
on Feb 13, 2013 at 16:24 UTC ( #1018568=note: print w/ replies, xml ) Need Help??


in reply to threads, file handles and wxPerl

I haven't found any way to get the handle from the thread to the main window loop

Try using the fileno of the filehandle. See FileHandles and threads for the basics. Also [threads] Open a file in one thread and allow others to write to it may yield a clue.


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh


Comment on Re: threads, file handles and wxPerl
Re^2: threads, file handles and wxPerl
by sdetweil (Sexton) on Feb 13, 2013 at 17:02 UTC
    thanks.. using the fileno() gets me the results I need.. (if you clone the handle as input when u need to write to it!. well you get what you get!)
    this is the output approach
    open my $fh, ">&=$CHILD_FILENO";

      Be careful. The file won't close until you close both handles; but you have to ensure than you do not close the first handle before the the thread has had a chance to clone it. You may need a shared var as a semaphore to coordinate things.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        thank you. I added close $fh; after the write in the event handler. I am letting the thread ending close the open3() created handles cause they were declared as local(). Should I do that explicitly? (adding it didn't cause any issues);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018568]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2015-07-03 20:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (56 votes), past polls