Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: spawning Perl scripts

by Abigail-II (Bishop)
on Mar 28, 2003 at 12:43 UTC ( #246455=note: print w/replies, xml ) Need Help??


in reply to spawning Perl scripts

$ cat long.pl #!/usr/bin/perl use strict; use warnings; print localtime () . ": Hello from $0 ($$)!\n"; sleep 30; print localtime () . ": Goodbye from $0 ($$)!\n"; __END__ $ cat fork.pl #!/usr/bin/perl use strict; use warnings; print localtime () . ": Hello from the parent ($$)!\n"; my $pid = fork; die "Fork failed: $!" unless defined $pid; unless ($pid) { print localtime () . ": Hello from the child ($$)!\n"; exec "./long.pl"; # Some long running process. die "Exec failed: $!\n"; } print localtime () . ": Goodbye from the parent ($$)!\n"; __END__ $ ./fork.pl Fri Mar 28 13:39:20 2003: Hello from the parent (458)! Fri Mar 28 13:39:20 2003: Goodbye from the parent (458)! Fri Mar 28 13:39:20 2003: Hello from the child (459)! Fri Mar 28 13:39:20 2003: Hello from ./long.pl (459)! Fri Mar 28 13:39:50 2003: Goodbye from ./long.pl (459)!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://246455]
help
Chatterbox?
talexb concurs .. almost 16 years here.
[TStanley]: Time flies when you're busy :D
LanX hasn't entered monk puberty yet
erix clocks 12 years
[TStanley]: talexb I was actually in your area last week. I was working in Milton, Ontario at the hospital they are building there.
Eily hasn't entered monk school

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2017-06-23 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (547 votes). Check out past polls.