http://qs321.pair.com?node_id=18924

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.
Re: How to kill a process after calling fork?
by Anonymous Monk on Dec 04, 2003 at 12: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.

Re: How to kill a process after calling fork?
by rraha (Initiate) on Nov 26, 2003 at 22: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.