Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: I want to launch two subroutines at once

by integral (Hermit)
on Feb 18, 2003 at 15:26 UTC ( #236274=note: print w/ replies, xml ) Need Help??


in reply to I want to launch two subroutines at once

The solution I can immediately think of is to create the activity bar (the 'monitoring process') first, and have it create the other as the child so that it knows its pid and can establish ipc structures before/after the fork. Something like the code below could be used.

pipe my $read, my $write; if (my $pid = fork()) { # monitor process close $write; read $read and update progress } else { close $read; while (1) { do stuff; print $write "status"; } }
This code does only creates the one other process however, so if you really want two subprocesses created you have to wrap it in another fork.

--
integral, resident of freenode's #perl


Comment on Re: I want to launch two subroutines at once
Download Code
Replies are listed 'Best First'.
Re: Re: I want to launch two subroutines at once
by juo (Curate) on Feb 18, 2003 at 16:39 UTC

    I have tried this code on Perl 5.6 - Windows 2000 and it generates Dr watson. Looks like Fork is not made for Windows 2000.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2015-09-03 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred temperature scale is:










    Results (105 votes), past polls