Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Perl: the Markov chain saw
 
PerlMonks  

How to kill a process after calling fork?

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

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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 01: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.
Re: How to kill a process after calling fork?
by rraha (Initiate) on Nov 26, 2003 at 17:52 UTC
    If you know the pid try using pslist -t and then pskill pid.They are downloadable apps from sysinternals.com

    Originally posted as a Categorized Answer.

Re: How to kill a process after calling fork?
by Anonymous Monk on Dec 04, 2003 at 07:53 UTC
    Good answer! Just add a comma between 'kill 1' and '$pid'.

    --
    Do You Yahoo?! NO, THANK YOU!
    Get rid of ads and banners in e-mail with Proxmail!
    http://proxmail.notlong.com

    Originally posted as a Categorized Answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://18924]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.