Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: spawning Perl scripts

by Abigail-II (Bishop)
on Mar 28, 2003 at 12:43 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://246455]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 23:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found