Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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)!


Comment on Re: spawning Perl scripts
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-07-25 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (170 votes), past polls