Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: fork and kill process

by rbc (Curate)
on Apr 25, 2002 at 23:03 UTC ( [id://162131]=note: print w/replies, xml ) Need Help??


in reply to fork and kill process

Here's a skeleton of what you might want to do ...
die "can't fork: $!" unless defined($kidpid = fork()); if ($kidpid) { # parent sleeps 60 seconds and then kills child sleep 60; kill("TERM" => $kidpid); # send SIGTERM to child } else { # child does wget ... } print "$kidpid exitting\n"; exit;
update
you might want to do your wget like so ...
... use LWP::Simple; #so you can do a get. ... die "can't fork: $!" unless defined($kidpid = fork()); if ($kidpid) { # parent sleeps 60 seconds and then kills child sleep 60; kill("TERM" => $kidpid); # send SIGTERM to child } else { my $data = get("http://www.example.com/"); ... }

Log In?
Username:
Password:

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

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

    No recent polls found