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

How to kill a process after calling fork?

by Anonymous Monk
on Jun 20, 2000 at 05:24 UTC ( #18924=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (programs and processes)

This is my code, $pid = fork; if($pid == 0) { exec " "; } How can I kill this process?

Originally posted as a Categorized Question.

  • Comment on How to kill a process after calling fork?

Replies are listed 'Best First'.
Re: How to kill a process after calling fork?
by chromatic (Archbishop) on Jun 20, 2000 at 05:56 UTC
    In the parent, if the fork call succeeds, $pid will contain the process ID of the child. You can then use the kill command to send any sort of signal to it (as you know the PID).
    my $pid = fork(); if ($pid == 0) { # we're the child # exec something or other } else { sleep 10; # give the child a chance kill 1, $pid; # nighty-night }
    Something along those lines will suffice.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2021-04-18 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?