Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

How to communicate w/ forked child under Strawberry

by shadrack (Acolyte)
on Dec 05, 2012 at 23:43 UTC ( #1007427=perlquestion: print w/replies, xml ) Need Help??
shadrack has asked for the wisdom of the Perl Monks concerning the following question:

Using Win32::GUI on Strawberry perl 5.16.2. According to the FAQ (http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=userguide-faq) the way to have a long-running "background" process not block the GUI is to do a fork(), and have the child do the work.

I've tested this and it works, but I'm unclear about how to pass a message from the parent to the child in this situation. If I was on UNIX, I'd just do something like

kill USR1 $childpid

but this is Windows, not UNIX, and apparently the return value of fork() is a "pseudo-thread ID" which perlfork says can by used by kill() EXCEPT THAT "the signal will not be delivered while the pseudo-process is blocked by a system call". Well, it just so happens that the child's innermost loop is a select() statement, so from a practical standpoint the child has just shy of a snowball's chance of ever receiving the signal sent by kill (I tested it). So my problem remains: given that fork() returns a "pseudo-thread ID" instead of a real PID or TID, how do I send a message from the parent to the child?

Replies are listed 'Best First'.
Re: How to communicate w/ forked child under Strawberry
by Anonymous Monk on Dec 06, 2012 at 14:07 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1007427]
Approved by GrandFather
help
Chatterbox?
[nysus]: What happened to the submit button? All I have is a preview button.
[erix]: perlmonks has become read-only ?
[marto]: erix unlikely, we've had posts within the last few minutes ;)
[ambrus]: nysus: make sure you enter at least two lines for the title and then preview, and read warnings the preview form prints
[davies]: There is an option (I have it set) to force preview before submission. Perhaps your option has been set (accidentally?) and you are not expecting it.
[ambrus]: sorry, I mean at least two words for the title and then preview

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (16)
As of 2017-12-15 11:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (431 votes). Check out past polls.

    Notices?